Submission #1264713

#TimeUsernameProblemLanguageResultExecution timeMemory
1264713SDAdzs1tgWatching (JOI13_watching)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define int long long using namespace std; const int maxn = 2001; int n, p, q, a[maxn], dp[maxn][maxn]; int c[maxn][2]; bool check(int mid) { dp[0][0] = 0; for(int i = 0; i <= p; i++) { for(int j = 0; j <= q; j++) { f[i][j] = 0; if(i > 0) { int last = dp[i - 1][j]; int t = upper_bound(a + 1, a + n + 1, a[min(n, last + 1)] + d - 1) - a - 1; dp[i][j] = max(dp[i][j], t); } if(j > 0) { int last = dp[i][j - 1]; int t = upper_bound(a + 1, a + n + 1, a[min(n, last + 1)] + 2 * d - 1) - a - 1; dp[i][j] = max(dp[i][j], t); } if(dp[i][j] >= n) { return true; } } } return false; } signed main () { cin >> n >> q >> p; for(int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); if(q + p >= 1) { cout << 1; return 0; } int l = 2, r = 1e9; while(l <= r) { int mid = (l + r) / 2; if(check(mid)) { l = mid + 1; } else r = mid - 1; } cout << r; }

Compilation message (stderr)

watching.cpp: In function 'bool check(long long int)':
watching.cpp:11:17: error: 'f' was not declared in this scope
   11 |                 f[i][j] = 0;
      |                 ^
watching.cpp:14:81: error: 'd' was not declared in this scope
   14 |                     int t = upper_bound(a + 1, a + n + 1, a[min(n, last + 1)] + d - 1) - a - 1;
      |                                                                                 ^
watching.cpp:19:85: error: 'd' was not declared in this scope
   19 |                     int t = upper_bound(a + 1, a + n + 1, a[min(n, last + 1)] + 2 * d - 1) - a - 1;
      |                                                                                     ^