Submission #468595

# Submission time Handle Problem Language Result Execution time Memory
468595 2021-08-28T23:50:59 Z pdstiago Watching (JOI13_watching) C++14
0 / 100
776 ms 163124 KB
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define mxn 205
#define mxm 100005
#define f first
#define s second
#define pb push_back
#define es " "
#define endl '\n'
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
 
int n, p, g, pos1[mxn], pos2[mxn], dp[mxn][mxm];
vector<int> v;
 
int solve(int i, int ss, int b){
    if(ss<0 || b<0){
        return 0;
    }
    if(i>=n){
        return 1;
    }
    if(dp[i][b]!=-1){
        return dp[i][b];
    }
    return dp[i][b]=max(solve(pos1[i]+1, ss-1, b), solve(pos2[i]+1, ss, b-1));
}
 
int main(){
    fastio;
    cin >> n >> p >> g;
    for(int i=1; i<=n; i++){
        int x;
        cin >> x;
        v.pb(x);
    }
    sort(all(v));
    int ini=1, fim=1000000000, meio, resp=1;
    while(ini<=fim){
        meio=(ini+fim)>>1;
        memset(pos1, 0, sizeof(pos1));
        memset(pos2, 0, sizeof(pos2));
        memset(dp, -1, sizeof(dp));
        for(int i=0; i<sz(v); i++){
            for(int j=sz(v)-1; j>=i; j--){
                if(v[j]-v[i]+1<=2*meio){
                    if(v[j]-v[i]+1<=meio){
                        pos1[i]=j;
                        break;
                    }else{
                        pos2[i]=max(pos2[i], j);
                    }
                }
            }
        }
        if(solve(0, p, g)){
            resp=meio;
            fim=meio-1;
        }else{
            ini=meio+1;
        }
    }
    cout << resp;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 353 ms 80452 KB Output is correct
2 Correct 332 ms 80532 KB Output is correct
3 Correct 348 ms 80460 KB Output is correct
4 Correct 331 ms 80496 KB Output is correct
5 Incorrect 776 ms 86788 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 146 ms 163124 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -