# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299965 | 2020-09-16T04:21:17 Z | T0p_ | Watching (JOI13_watching) | C++14 | 681 ms | 11776 KB |
#include<bits/stdc++.h> using namespace std; int n, p, q; long long arr[2020], dp[2020][2020]; int EndPoint(int s, long long w) { if(s > n) return n; int l = s, r = n; while(l != r) { int mid = (l+r+1)>>1; (arr[s] + w - 1 >= arr[mid]) ? l = mid : r = mid-1; } return l; } bool Test(long long w) { for(int i=1 ; i<=p ; i++) dp[i][0] = EndPoint(dp[i-1][0]+1, w); for(int i=1 ; i<=q ; i++) dp[0][i] = EndPoint(dp[0][i-1]+1, w+w); for(int i=1 ; i<=p ; i++) for(int j=1 ; j<=q ; j++) dp[i][j] = max(EndPoint(dp[i-1][j]+1, w), EndPoint(dp[i][j-1]+1, w+w)); return dp[p][q] == n; } int main() { scanf(" %d %d %d",&n,&p,&q); for(int i=1 ; i<=n ; i++) scanf(" %lld",&arr[i]); sort(arr+1, arr+n+1); if(p+q >= n) printf("1\n"); else { long long l = 1, r = 1e9; while(l != r) { long long mid = (l+r)>>1; (Test(mid)) ? r = mid : l = mid + 1; } printf("%lld\n",l); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 360 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 288 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 512 KB | Output is correct |
12 | Correct | 2 ms | 500 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 1 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 117 ms | 1536 KB | Output is correct |
9 | Correct | 127 ms | 4172 KB | Output is correct |
10 | Correct | 153 ms | 9368 KB | Output is correct |
11 | Correct | 126 ms | 1808 KB | Output is correct |
12 | Correct | 681 ms | 11776 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |