# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
363253 | 2021-02-05T11:43:10 Z | denkendoemeer | Sparklers (JOI17_sparklers) | C++14 | 1 ms | 364 KB |
#include<bits/stdc++.h> #define ll long long const ll inf=1e18; using namespace std; ll t,x[100005],dp[100005]; int n,k; bool calc(ll nr) { nr=nr*2; if (t*nr>(ll)1e9) return 1; int i; for(i=1;i<=n;i++) dp[i]=x[i]-i*t*nr; int st=1,dr=n; for(i=1;i<=k;i++) if (dp[st]<=dp[i]) st=i; for(i=k;i<=n;i++) if (dp[dr]>=dp[i]) dr=i; int l=k,r=k; ll v1=dp[l],v2=dp[r]; while(st<=l || r<=dr){ int auxl=l,auxr=r; while(l>=st && dp[l]>=v2){ v1=max(v1,dp[l]); l--; } while(r<=dr && dp[r]<=v1){ v2=min(v2,dp[r]); r++; } if (l==auxl && r==auxr) return 0; } l=1; r=n; v1=dp[l]; v2=dp[r]; while(l<=st && dr<=r){ int auxl=l,auxr=r; while(l<=st && dp[l]>=v2){ v1=max(v1,dp[l]); l++; } while(r>=dr && dp[r]<=v1){ v2=min(v2,dp[r]); r--; } if (l==auxl && r==auxr) return 0; } return 1; } int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); scanf("%d%d%lld",&n,&k,&t); int i; for(i=1;i<=n;i++) scanf("%lld",&x[i]); ll st=0,dr=1e9,mij,last; while(st<=dr){ mij=(st+dr)/2; if (calc(mij)){ last=mij; dr=mij-1; } else st=mij+1; } printf("%lld\n",last); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Incorrect | 1 ms | 364 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |