Submission #804395

# Submission time Handle Problem Language Result Execution time Memory
804395 2023-08-03T08:31:12 Z 이동현(#10103) Fun Palace (CCO18_fun) C++17
0 / 25
27 ms 47492 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

const int fsz = 1004, ssz = 3004;
int dp[fsz][ssz][2];
int a[1004], b[1004];

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, e;
    cin >> n >> e;
    for(int i = 2; i <= n; ++i){
        cin >> a[i] >> b[i];
    }
    b[1] = e;
    a[n + 1] = (int)1e9;

    for(int i = 0; i < fsz; ++i){
        for(int j = 0; j < ssz; ++j){
            dp[i][j][0] = dp[i][j][1] = -(int)1e18;
        }
    }

    dp[n][0][1] = dp[n][0][0] = 0;
    for(int i = n; i >= 1; --i){
        for(int j = 0; j < ssz; ++j){
            dp[i][j][0] = max(dp[i][j][0], dp[i][j][1]);
            for(int k = 0; k <= a[i + 1]; ++k){
                int go = j + k;
                if(go <= a[i] + b[i]){
                    go = max(0ll, go - b[i]);
                }

                if(go >= ssz) break;

                
                dp[i - 1][go][0] = max(dp[i - 1][go][0], dp[i][j][1] + k);
                if(!k) dp[i - 1][go][1] = max(dp[i - 1][go][1], dp[i][j][0]);
            }

            // cout << i << ' ' << j << ' ' << dp[i][j] << endl;
        }
    }

    cout << max(dp[0][0][0], dp[0][0][1]) << '\n';
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 47444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 47492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 47444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 47444 KB Output isn't correct
2 Halted 0 ms 0 KB -