Submission #63493

# Submission time Handle Problem Language Result Execution time Memory
63493 2018-08-02T01:21:18 Z mra2322001 Watching (JOI13_watching) C++14
0 / 100
16 ms 8560 KB
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)

using namespace std;
typedef long long ll;
const int N = 2002;

int n, f[N][N];
int a[N], huge, tiny;
int lon[N], nho[N];

bool check(int mid){
    f1(i, n){
        int vt = lower_bound(a + 1, a + n + 1, a[i] - mid + 1) - a;
        int vt2 = lower_bound(a + 1, a + n + 1, a[i] - 2*mid + 1) - a;
        lon[i] = vt2;
        nho[i] = vt;
    }
    f0(i, tiny + 1) f[0][i] = 0;
    f1(i, n){
        f0(j, tiny + 1){
            /// nho
            int k = nho[i] - 1;
            if(j > 0){
                f[i][j] = min(f[i][j], f[k][j - 1]);
            }
            k = lon[i] - 1;
            int g = f[k][j] + 1;
            if(g > huge) g = 1e9;
            f[i][j] = min(f[i][j], g);
        }
    }
    f0(j, tiny + 1) if(f[n][j] <= huge) return 1;
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);
 
    cin >> n >> tiny >> huge;
    f1(i, n) cin >> a[i];
    if(tiny + huge >= n){
        cout << 1;
        return 0;
    }

    sort(a + 1, a + n + 1);
    int l = 0, r = 1e6 + 2, ans = r;

    while(l <= r){
        int mid = (l + r)/2;
        f1(i, n) f0(j, tiny + 1) f[i][j] = 1e9;
        if(check(mid)) r = mid - 1, ans = mid;
        else l = mid + 1;
    }
    cout << ans;
}

# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 8560 KB Output isn't correct
2 Halted 0 ms 0 KB -