# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112147 | 2019-05-17T15:42:06 Z | dolphingarlic | Watching (JOI13_watching) | C++14 | 174 ms | 16256 KB |
#include<bits/stdc++.h> using namespace std; #define taskname "A" #define pb push_back #define mp make_pair #ifndef LOCAL #define cerr if(0)cout #endif typedef long double ld; typedef long long ll; typedef pair<int,ll> ii; const int maxn = 2005; int n , q , p; int a[maxn]; int dp[maxn][maxn]; bool chk(int w){ dp[0][0] = 0; int ii = 1 , jj = 1; for(int i = 1 ; i <= n ; ++i){ while(a[i] - a[ii] + 1 > w)++ii; while(a[i] - a[jj] + 1 > 2 * w)++jj; // cout << ii << " " << jj << " " << i << endl; for(int j = 0 ; j <= i && j <= p ; ++j){ if(j == 0)dp[i][j] = dp[jj - 1][j] + 1; else dp[i][j] = min(dp[jj - 1][j] + 1 , dp[ii - 1][j - 1]),dp[i][j] = min(dp[i][j] , dp[i][j - 1]); } } // cout << w << " " << dp[n][min(p,n)] << endl; return dp[n][min(p,n)] <= q; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen(taskname".INP","r")){ freopen(taskname".INP", "r",stdin); freopen(taskname".OUT", "w",stdout); } cin >> n >> p >> q; int l = 1 , h = 1e9; for(int i = 1 ; i <= n ; ++i)cin >> a[i]; sort(a + 1 , a + n + 1); fill_n(&dp[0][0],maxn*maxn,q + 1); while(l <= h){ int mid = l + h >> 1; if(!chk(mid))l = mid + 1; else h = mid - 1; // return 0; } cout << l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 16128 KB | Output is correct |
2 | Correct | 13 ms | 16000 KB | Output is correct |
3 | Correct | 13 ms | 16000 KB | Output is correct |
4 | Correct | 13 ms | 16128 KB | Output is correct |
5 | Correct | 13 ms | 16000 KB | Output is correct |
6 | Correct | 13 ms | 16000 KB | Output is correct |
7 | Correct | 13 ms | 16128 KB | Output is correct |
8 | Correct | 13 ms | 16128 KB | Output is correct |
9 | Correct | 13 ms | 16128 KB | Output is correct |
10 | Correct | 13 ms | 16128 KB | Output is correct |
11 | Correct | 13 ms | 16120 KB | Output is correct |
12 | Correct | 13 ms | 16128 KB | Output is correct |
13 | Correct | 13 ms | 16128 KB | Output is correct |
14 | Correct | 13 ms | 16128 KB | Output is correct |
15 | Correct | 13 ms | 16128 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 16000 KB | Output is correct |
2 | Correct | 13 ms | 16040 KB | Output is correct |
3 | Correct | 162 ms | 16120 KB | Output is correct |
4 | Correct | 170 ms | 16128 KB | Output is correct |
5 | Correct | 27 ms | 16128 KB | Output is correct |
6 | Correct | 169 ms | 16136 KB | Output is correct |
7 | Correct | 16 ms | 16128 KB | Output is correct |
8 | Correct | 36 ms | 16128 KB | Output is correct |
9 | Correct | 114 ms | 16256 KB | Output is correct |
10 | Correct | 174 ms | 16128 KB | Output is correct |
11 | Correct | 29 ms | 16176 KB | Output is correct |
12 | Correct | 134 ms | 16220 KB | Output is correct |
13 | Correct | 16 ms | 16128 KB | Output is correct |
14 | Correct | 17 ms | 16128 KB | Output is correct |
15 | Correct | 16 ms | 16128 KB | Output is correct |