Submission #944441

# Submission time Handle Problem Language Result Execution time Memory
944441 2024-03-12T17:45:16 Z cot Watching (JOI13_watching) C++14
0 / 100
103 ms 64420 KB
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define r0 return 0
using namespace std;
const int N = 2005;
int n,m,p,q,a[N],l1,l2,l,r,ans;
set < pii > s;
int dp[N][N];
bool check (int x) {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= n; j++) dp[i][j] = 1e9;
        for (int j = 0; j <= i; j++) {
            // patara kamera
            if (j >= 1) {
                auto it = s.lower_bound({a[i] - x + 1, 0});
                it--;
                l1 = (*it).ss;
                dp[i][j] = dp[l1][j - 1];  
            }
            // didi kamera
            auto it2 = s.lower_bound({a[i] - 2 * x + 1, 0});
            it2--;
            l2 = (*it2).ss;
            dp[i][j] = min(dp[i][j], dp[l2][j] + 1);
            if (i == n and j <= p and dp[i][j] <= q) return 1;
        }
    }
    return 0;
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> p >> q;
    s.insert({0, 0});
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s.insert({a[i], i});
    }
    sort(a + 1, a + 1 + n);
    l = 1; r = a[n];
    while (l <= r) {
        int mid = (l + r) / 2;
        if(check(mid)) {
            ans = mid;
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }
    cout << ans << endl;
    r0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 4700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 64420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -