Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 100 + 5;
- const int C = 40 + 5;
- int dp[N][C];
- bool isFree[N];
- int main(){
- int n, nNotFree;
- scanf("%d%d", &n, &nNotFree);
- for(int i = 1; i <= n; ++i){
- isFree[i] = true;
- }
- for(int i = 1; i <= nNotFree; ++i){
- int x;
- scanf("%d", &x);
- isFree[x] = false;
- }
- int mxCoupon = n / 5 * 2;
- for(int i = n; i >= 1; --i){
- for(int c = 0; c <= mxCoupon; ++c){
- if(!isFree[i]){
- dp[i][c] = dp[i + 1][c];
- continue;
- }
- int mn = 1e9;
- if(c >= 3){
- mn = min(mn, dp[i + 1][c - 3]);
- }
- if(i + 4 <= n){
- mn = min(mn, 37000 + dp[i + 5][c + 2]);
- }
- if(i + 2 <= n){
- mn = min(mn, 25000 + dp[i + 3][c + 1]);
- }
- mn = min(mn, 10000 + dp[i + 1][c]);
- dp[i][c] = mn;
- }
- }
- cout << dp[1][0];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement