# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27779 | 2017-07-14T05:38:44 Z | 서규호(#1160) | Sparklers (JOI17_sparklers) | C++14 | 0 ms | 2800 KB |
#include <bits/stdc++.h> #define lld long long #define pii pair<int,int> #define pll pair<lld,lld> #define pb push_back #define next nextt #define left leftt #define right rightt #define Inf 1000000000 #define Linf 1000000000000000000LL #define Mod 1000000007 using namespace std; int N,M,ans; lld T; lld a[100002]; bool can(lld X){ X *= T; X %= Mod; int l,r,cnt; lld s,e; l = r = M; cnt = 1; s = e = a[M]; while(r-l != N-1){ if(l != 1 && max(s-X,a[l-1]-X*cnt) <= min(e+X,a[l-1]+X*cnt)){ s = max(s-X,a[l-1]-X*cnt); e = min(e+X,a[l-1]+X*cnt); l--; }else if(r != N && max(s-X,a[r+1]-X*cnt) <= min(e+X,a[r+1]+X*cnt)){ s = max(s-X,a[r+1]-X*cnt); e = min(e+X,a[r+1]+X*cnt); r++; }else return false; s = max((lld)0,s); e = min(e,(lld)Mod); cnt++; } return true; } int main(){ scanf("%d %d %lld",&N,&M,&T); for(int i=1; i<=N; i++){ scanf("%lld",&a[i]); } int l,r; l = 0; r = a[N]; while(l <= r){ int m = (l+r)/2; if(can(m)){ ans = m; r = m-1; }else l = m+1; } printf("%d\n",ans); return 0; }
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 | - |