Submission #849997

# Submission time Handle Problem Language Result Execution time Memory
849997 2023-09-15T15:27:33 Z Ahmed57 Event Hopping (BOI22_events) C++17
0 / 100
1500 ms 8284 KB
#include <bits/stdc++.h>
using namespace std;
int dp[2][505000*2+1],arr[301];
int br = 505000,n,m;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>n;
    for(int i = 0;i<2*m+1;i++){
        cin>>arr[i];
    }
    for(int i = 2*m+1;i>=0;i--){
        for(int j = 0;j<=(i<=m?505000:505000*2);j++){
            if(i==2*m+1){
                if(j==n+br){
                    dp[i&1][j] = 0;
                }else{
                    dp[i&1][j] = -3e4;
                }
                continue;
            }
            int ans = -3e4;
            for(int e = 0;e<=arr[i];e++){
                if(j+e*(i-m)>505000*2)break;
                if(j+e*(i-m)<0)continue;
                ans = max(ans,dp[!(i&1)][j+e*(i-m)]+e);
            }
            dp[i&1][j] = ans;
        }
    }
    long long vl = dp[0][505000];
    if(vl<0)cout<<"impossible\n";
    else cout<<vl<<endl;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1551 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1552 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1551 ms 8280 KB Time limit exceeded
2 Halted 0 ms 0 KB -