# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27833 | 2017-07-14T07:38:15 Z | 김동현(#1158) | Sparklers (JOI17_sparklers) | C++14 | 66 ms | 2800 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; ll x[100010], t; int can(ll v){ for(int i = 0; i < (1 << (n - 1)); i++){ if(__builtin_popcount(i) != k - 1) continue; int l = k - 1, r = k + 1, cnt = 0; ll s = x[k], e = x[k]; int fl = 1; for(int j = 0; j < n - 1; j++){ int c; cnt++; if((i >> j) & 1) c = l--; else c = r++; s -= v * t; e += v * t; ll ts = x[c] - v * cnt * t, te = x[c] + v * cnt * t; s = max(s, ts); e = min(e, te); if(s > e){ fl = 0; break; } } if(fl) return 1; } return 0; } int main(){ scanf("%d%d%lld", &n, &k, &t); if(n == 1){ puts("0"); return 0; } for(int i = 1; i <= n; i++) scanf("%lld", x + i); ll s = 1, e = 2 * ((ll(1e9) + t - 1) / t); for(int m; s <= e; ){ m = (s + e) / 2; if(can(m)) e = m - 1; else s = m + 1; } printf("%lld\n", s); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2800 KB | Output is correct |
2 | Correct | 0 ms | 2800 KB | Output is correct |
3 | Correct | 0 ms | 2800 KB | Output is correct |
4 | Correct | 33 ms | 2800 KB | Output is correct |
5 | Correct | 49 ms | 2800 KB | Output is correct |
6 | Correct | 49 ms | 2800 KB | Output is correct |
7 | Correct | 26 ms | 2800 KB | Output is correct |
8 | Correct | 26 ms | 2800 KB | Output is correct |
9 | Correct | 26 ms | 2800 KB | Output is correct |
10 | Correct | 19 ms | 2800 KB | Output is correct |
11 | Correct | 9 ms | 2800 KB | Output is correct |
12 | Correct | 23 ms | 2800 KB | Output is correct |
13 | Correct | 66 ms | 2800 KB | Output is correct |
14 | Correct | 43 ms | 2800 KB | Output is correct |
15 | Correct | 29 ms | 2800 KB | Output is correct |
16 | Correct | 33 ms | 2800 KB | Output is correct |
17 | Correct | 19 ms | 2800 KB | Output is correct |
18 | Correct | 19 ms | 2800 KB | Output is correct |
19 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2800 KB | Output is correct |
2 | Correct | 0 ms | 2800 KB | Output is correct |
3 | Correct | 0 ms | 2800 KB | Output is correct |
4 | Correct | 33 ms | 2800 KB | Output is correct |
5 | Correct | 49 ms | 2800 KB | Output is correct |
6 | Correct | 49 ms | 2800 KB | Output is correct |
7 | Correct | 26 ms | 2800 KB | Output is correct |
8 | Correct | 26 ms | 2800 KB | Output is correct |
9 | Correct | 26 ms | 2800 KB | Output is correct |
10 | Correct | 19 ms | 2800 KB | Output is correct |
11 | Correct | 9 ms | 2800 KB | Output is correct |
12 | Correct | 23 ms | 2800 KB | Output is correct |
13 | Correct | 66 ms | 2800 KB | Output is correct |
14 | Correct | 43 ms | 2800 KB | Output is correct |
15 | Correct | 29 ms | 2800 KB | Output is correct |
16 | Correct | 33 ms | 2800 KB | Output is correct |
17 | Correct | 19 ms | 2800 KB | Output is correct |
18 | Correct | 19 ms | 2800 KB | Output is correct |
19 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2800 KB | Output is correct |
2 | Correct | 0 ms | 2800 KB | Output is correct |
3 | Correct | 0 ms | 2800 KB | Output is correct |
4 | Correct | 33 ms | 2800 KB | Output is correct |
5 | Correct | 49 ms | 2800 KB | Output is correct |
6 | Correct | 49 ms | 2800 KB | Output is correct |
7 | Correct | 26 ms | 2800 KB | Output is correct |
8 | Correct | 26 ms | 2800 KB | Output is correct |
9 | Correct | 26 ms | 2800 KB | Output is correct |
10 | Correct | 19 ms | 2800 KB | Output is correct |
11 | Correct | 9 ms | 2800 KB | Output is correct |
12 | Correct | 23 ms | 2800 KB | Output is correct |
13 | Correct | 66 ms | 2800 KB | Output is correct |
14 | Correct | 43 ms | 2800 KB | Output is correct |
15 | Correct | 29 ms | 2800 KB | Output is correct |
16 | Correct | 33 ms | 2800 KB | Output is correct |
17 | Correct | 19 ms | 2800 KB | Output is correct |
18 | Correct | 19 ms | 2800 KB | Output is correct |
19 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |