# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
952186 | 2024-03-23T09:15:40 Z | SmuggingSpun | Watching (JOI13_watching) | C++14 | 231 ms | 15560 KB |
#include<bits/stdc++.h> #define taskname "watching" using namespace std; const int INF = 1e9; const int lim = 2e3 + 5; int a[lim]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } int n, p, q, ans, low = 1, high = 1e9; cin >> n >> p >> q; for(int i = 1; i <= n; i++){ cin >> a[i]; } if(p + q >= n){ return cout << 1, 0; } sort(a + 1, a + n + 1); while(low <= high){ int mid = (low + high) >> 1; vector<vector<int>>dp(n + 1, vector<int>(q + 1, INF)); for(int i = 0; i <= q; i++){ dp[0][i] = 0; } for(int i = 1, lp = 1, lq = 1; i <= n; i++){ while(a[i] - a[lp] >= mid){ lp++; } while(a[i] - a[lq] >= (mid << 1)){ lq++; } dp[i][0] = dp[lp - 1][0] + 1; for(int j = 1; j <= q; j++){ dp[i][j] = min(dp[lq - 1][j - 1], dp[lp - 1][j] + 1); } } if(dp[n][q] <= p){ high = (ans = mid) - 1; } else{ low = mid + 1; } } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 388 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 452 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 356 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 3 ms | 600 KB | Output is correct |
8 | Correct | 87 ms | 6620 KB | Output is correct |
9 | Correct | 16 ms | 1576 KB | Output is correct |
10 | Correct | 12 ms | 1236 KB | Output is correct |
11 | Correct | 231 ms | 15560 KB | Output is correct |
12 | Correct | 110 ms | 8320 KB | Output is correct |
13 | Correct | 4 ms | 604 KB | Output is correct |
14 | Correct | 3 ms | 604 KB | Output is correct |
15 | Correct | 3 ms | 604 KB | Output is correct |