# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27843 | 2017-07-14T07:59:01 Z | 김동현(#1158) | Sparklers (JOI17_sparklers) | C++14 | 0 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){ int l = k - 1, r = k + 1, cnt = 0; ll s = x[k], e = x[k]; for(int j = 0; j < n - 1; j++){ int c; cnt++; if(l >= 1 && (r > n || e - x[l] < x[r] - s)) 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) return 0; } return 1; } int main(){ scanf("%d%d%lld", &n, &k, &t); for(int i = 1; i <= n; i++) scanf("%lld", x + i); ll s = 0, e = 2 * ((ll(1e9) + t - 1) / t); for(ll m; s <= e; ){ m = (s + e) / 2; if(can(m)) e = m - 1; else s = m + 1; } printf("%lld\n", s); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 2800 KB | Output is correct |
5 | Correct | 0 ms | 2800 KB | Output is correct |
6 | Correct | 0 ms | 2800 KB | Output is correct |
7 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 2800 KB | Output is correct |
5 | Correct | 0 ms | 2800 KB | Output is correct |
6 | Correct | 0 ms | 2800 KB | Output is correct |
7 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 2800 KB | Output is correct |
5 | Correct | 0 ms | 2800 KB | Output is correct |
6 | Correct | 0 ms | 2800 KB | Output is correct |
7 | Incorrect | 0 ms | 2800 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |