# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48680 | 2018-05-17T20:42:11 Z | Pajaraja | Watching (JOI13_watching) | C++17 | 3 ms | 376 KB |
#include <bits/stdc++.h> #define MAXN 2007 using namespace std; int n,p,q,a[MAXN],dp[MAXN][MAXN]; int provera(int x) { int t1=0,t2=0,t3=1; for(int i=1;i<=q;i++) dp[i][0]=1000000000; dp[0][0]=0; while(t3<=n) { while(t1<t3 && a[t3]-a[t1+1]>=2*x) t1++; while(t2<t3 && a[t3]-a[t2+1]>=x) t2++; for(int i=0;i<=q;i++) { dp[i][t3]=1000000000; if(i>0) dp[i][t3]=min(dp[i-1][t1],dp[i][t3]); dp[i][t3]=min(dp[i][t2]+1,dp[i][t3]); } t3++; } for(int i=0;i<=q;i++) if(dp[i][n]<=p) return true; return false; } int binarna(int l,int r) { if(l==r) return l; int s=(l+r)/2; if(provera(s)) return binarna(l,s); return binarna(s+1,r); } int main() { scanf("%d%d%d",&n,&p,&q); if(p+q>=n) {printf("1"); return 0;} for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); a[0]=-1000000000; printf("%d",binarna(1,(a[n]-a[1])/(p+2*q))); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |