# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1174234 | nguyenkhangninh99 | Watching (JOI13_watching) | C++17 | 121 ms | 16164 KiB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
int a[maxn], dp[maxn][maxn], prep[maxn], preq[maxn];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, p, q; cin >> n >> p >> q;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n);
if (n <= p + q) cout << 1;
else{
int ans = 0;
for (int bit = 29; bit >= 0; bit--) {
int cur = ans | (1 << bit), pp = 0, pq = 0;
for(int i = 1; i <= n; i++){
while(pp + 1 <= n && a[i] - a[pp + 1] >= cur) pp++;
while(pq + 1 <= n && a[i] - a[pq + 1] >= 2 * cur) pq++;
prep[i] = pp;
preq[i] = pq;
}
for (int i = 1; i <= n; i++){
for (int j = 0; j <= q; j++){
dp[i][j] = dp[prep[i]][j] + 1;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |