Submission #29453

#TimeUsernameProblemLanguageResultExecution timeMemory
29453kdh9949Taxis (POI13_tak)C++14
60 / 100
169 ms5924 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, t;
ll d, b, x, a[500010];

int main(){
	scanf("%lld%lld%d", &d, &b, &n);
	for(int i = 0; i < n; i++) scanf("%lld", a + i);
	sort(a, a + n, greater<int>());
	t = int(upper_bound(a, a + n, d - b, greater<int>()) - a - 1);
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(a[i] >= max(d - b, b + d - 2 * x)){
			printf("%d\n", cnt + 1);
			return 0;
		}
		if(i == t) continue;
		x += a[i] - (b - x);
		cnt++;
		if(a[t] >= max(d - b, b + d - 2 * x)){
			printf("%d\n", cnt + 1);
			return 0;
		}
	}
	puts("0");
}

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:9:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%d", &d, &b, &n);
                                 ^
tak.cpp:10:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i < n; i++) scanf("%lld", a + i);
                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...