Submission #964200

#TimeUsernameProblemLanguageResultExecution timeMemory
964200UnforgettableplWatching (JOI13_watching)C++17
0 / 100
37 ms33060 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...