Submission #964200

# Submission time Handle Problem Language Result Execution time Memory
964200 2024-04-16T12:08:29 Z Unforgettablepl Watching (JOI13_watching) C++17
0 / 100
37 ms 33060 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef long long ll;

pair<bool,int> DP[101][101][101];
int arr[101];
int n,p,q;

bool check(int w){
    for(auto&i:DP)for(auto&j:i)for(auto&k:j)k={false,0ll};
    for(auto&i:DP[0])for(auto&j:i)j.first=true;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=p;j++){
            for(int k=0;k<=q;k++){
                if(DP[i-1][j][k].second>=arr[i] and DP[i-1][j][k].first)DP[i][j][k]=DP[i-1][j][k];
                if(j!=0 and DP[i-1][j-1][k].first)DP[i][j][k]=max(DP[i][j][k],{true,arr[i]+2*w-1});
                if(k!=0 and DP[i-1][j][k-1].first)DP[i][j][k]=max(DP[i][j][k],{true,arr[i]+w-1});
            }
        }
    }
    return !DP[n][p][q].first;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> p >> q;
    for(int i=1;i<=n;i++)cin>>arr[i];
    if(p+q>=n){
        cout << "1\n";
        return 0;
    }
    int ans = 0;
    for(int jump=536870912;jump;jump/=2){
        if(check(ans+jump))ans+=jump;
    }
    ans++;
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 16568 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 17 ms 33060 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -