Submission #28994

# Submission time Handle Problem Language Result Execution time Memory
28994 2017-07-18T04:05:47 Z 김동현(#1169) Railway Trip (JOI17_railway_trip) C++14
0 / 100
39 ms 9832 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, t, ans;
ll d, b, a[500010], s[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>());
	ans = n + 1;
	for(int i = 0; i < n; i++){
		s[i] = (i ? s[i - 1] : 0LL) + max(0LL, a[i] - b + (i ? s[i - 1] : 0LL));
		s[i] = min(b, s[i]);
	}
	for(int i = n - 1; i >= 0; i--){
		if(a[i] < d - b) continue;
		if(a[i] >= d + b){ ans = 1; continue; }
		ll tx = (d + b - a[i] + 1) / 2;
		ans = min(ans, int(lower_bound(s, s + n, tx) - a + 1));
	}
	printf("%d\n", ans % (n + 1));
}

Compilation message

railway_trip.cpp: In function 'int main()':
railway_trip.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);
                                 ^
railway_trip.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 time Memory Grader output
1 Incorrect 0 ms 9832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 9832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 9832 KB Output isn't correct
2 Halted 0 ms 0 KB -