# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
37081 | 2017-12-21T05:06:26 Z | szawinis | Taxis (POI13_tak) | C++14 | 223 ms | 5920 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5+1; int n; ll m, d, x[N]; bool check(int lim_idx) { ll curr = 0; int rem = upper_bound(x+1, x+lim_idx+1, m - d, greater<ll>()) - x - 1; if(!rem) return false; for(int i = 1; i < rem && curr < d; i++) curr += max(x[i] - (d - curr), 0ll); for(int i = rem + 1; i <= lim_idx && curr < d; i++) curr += max(x[i] - (d - curr), 0ll); if(curr < d) return x[rem] - 2 * (d - curr) >= m - d; else return true; } int main() { scanf("%lld %lld %d", &m, &d, &n); for(int i = 1; i <= n; i++) scanf("%lld", x+i); sort(x+1, x+n+1, greater<ll>()); int l = 1, r = n; while(l < r) { int mid = l+r >> 1; if(check(mid)) r = mid; else l = mid+1; } if(!check(l)) printf("0"); else printf("%d", l); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5920 KB | Output is correct |
2 | Correct | 0 ms | 5920 KB | Output is correct |
3 | Correct | 0 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5920 KB | Output is correct |
2 | Correct | 0 ms | 5920 KB | Output is correct |
3 | Correct | 0 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5920 KB | Output is correct |
2 | Correct | 0 ms | 5920 KB | Output is correct |
3 | Correct | 0 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5920 KB | Output is correct |
2 | Correct | 0 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 5920 KB | Output is correct |
2 | Correct | 3 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 5920 KB | Output is correct |
2 | Correct | 26 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 5920 KB | Output is correct |
2 | Correct | 76 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 113 ms | 5920 KB | Output is correct |
2 | Correct | 153 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 189 ms | 5920 KB | Output is correct |
2 | Correct | 143 ms | 5920 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 5920 KB | Output is correct |
2 | Correct | 223 ms | 5920 KB | Output is correct |