Submission #468525

#TimeUsernameProblemLanguageResultExecution timeMemory
468525mychecksedad구경하기 (JOI13_watching)C++17
50 / 100
32 ms3372 KiB
#include<bits/stdc++.h> using namespace std; const int N = 110, MX = 1e9; int n, p, q, arr[N], dp[N][N][N]; bool check(int w){ for(int i = 0; i <= n+1; i++) for(int j = 0; j <= p+1; j++) for(int k = 0; k <= q+1; k++) dp[i][j][k] = -1; dp[0][0][0] = 0; for(int i = 1; i <= n; i++){ for(int j = 0; j <= p; j++){ for(int k = 0; k <= q; k++){ if(k==j&&k==0) continue; if(j > 0 && dp[i - 1][j - 1][k] > -1){ dp[i][j][k] = max(dp[i][j][k], arr[i] + w); } if(k > 0 && dp[i - 1][j][k - 1] > -1){ dp[i][j][k] = max(dp[i][j][k], arr[i] + 2*w); } if(dp[i - 1][j][k] > arr[i]) dp[i][j][k] = max(dp[i - 1][j][k], dp[i][j][k]); // cout << dp[i][j][k] << " . " << j << ' ' << k << " | "; } // cout << '\n'; } // cout << '\n'; } // cout << '\n'; return (dp[n][p][q] > -1); } int main(){ cin >> n >> p >> q; for(int i = 1; i <= n; i++) cin >> arr[i]; if(p + q >= n){ cout << 1; return 0; } sort(arr+1, arr+n+1); int l = 1, h = MX, ans = MX; while(l <= h){ int mid = ((l+h)>>1); if(check(mid)){ ans = min(ans, mid); h = mid - 1; }else l = mid + 1; } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...