Submission #3413996


Source Code Expand

// Skqliao
#include <bits/stdc++.h>

#define rep(i, l, r) for (__typeof(l) i = (l), _##i##_ = (r); i < _##i##_; ++i)
#define rof(i, l, r) for (__typeof(l) i = (l) - 1, _##i##_ = (r); i >= _##i##_; --i)
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
template<typename T> bool chkMax(T &x, const T& y) {return x < y ? (x = y), 1 : 0;}
template<typename T> bool chkMin(T &x, const T& y) {return x > y ? (x = y), 1 : 0;}
typedef long long ll;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define DEBUG debug("passing %d in %s\n", __LINE__, __FUNCTION__)

const int MAXN = 500000 + 5;

char Str[MAXN];
int N;

bool check(int x) {
	static int A[MAXN];
	int len = N - 1, sum = 0;
	rep(i, 0, N) {
		A[i] = (Str[i] - '0') * 9;
	}
	A[0] += 9 * x;
	for(int i = 0; i <= len; ++i) {
		if(i == len && A[i] > 9) {
			A[++len] = 0;
		}
		A[i + 1] += A[i] / 10;
		A[i] %= 10; 
		sum += A[i];
	}
	return sum <= 9 * x;
}

int main() {
	scanf("%s", Str);
	N = strlen(Str);
	std::reverse(Str, Str + N);
	int l = 1, r = N;
	int ans = 0;
	while(l <= r) {
		int m = (l + r) >> 1;
		if(check(m)) {
			ans = m;
			r = m - 1;
		} else {
			l = m + 1;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task A - Airport Bus
User Skqliao
Language C++ (GCC 5.4.1)
Score 0
Code Size 1238 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:39:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s", Str);
                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
WA × 2
WA × 12
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt WA 1 ms 256 KB
in2.txt WA 1 ms 256 KB
in3.txt WA 1 ms 256 KB
in4.txt WA 1 ms 256 KB
in5.txt WA 1 ms 256 KB
in6.txt WA 1 ms 256 KB
in7.txt WA 1 ms 256 KB
in8.txt WA 1 ms 256 KB
sample1.txt WA 1 ms 256 KB
sample2.txt WA 1 ms 256 KB