Submission #28993

# Submission time Handle Problem Language Result Execution time Memory
28993 2017-07-18T04:03:10 Z 김동현(#1169) Arranging Tickets (JOI17_arranging_tickets) C++14
0 / 100
0 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

arranging_tickets.cpp: In function 'int main()':
arranging_tickets.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);
                                 ^
arranging_tickets.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 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 0 ms 9832 KB Output isn't correct
2 Halted 0 ms 0 KB -