Submission #721897

#TimeUsernameProblemLanguageResultExecution timeMemory
721897sunnatUplifting Excursion (BOI22_vault)C++14
5 / 100
641 ms2460 KiB
#include <algorithm> #include <iostream> #include <vector> #include <queue> #include <cmath> #include <map> #include <set> using namespace std; int main(){ vector<int> dp[2]; int n, m, res = -1; cin >> n >> m; vector<int>a(2*n+1); int q = 65000; for(int i = 0; i < a.size(); i ++) cin >> a[i]; dp[1].resize(2*q+1, -1); dp[1][q] = 0; for(int val = -n; val <= n; val ++){ // cout << val << endl; if(val == 0) continue; dp[0] = dp[1]; int v = val + n; for(int cnt = 1; cnt <= a[v]; cnt ++){ for(int sum = -q; sum <= q; sum ++){ if(dp[1][sum+q] != -1) //if(-q <= sum+val*cnt && sum+val*cnt <= q) dp[0][sum+val*cnt+q] = max(dp[0][sum+val*cnt+q], dp[1][sum+q] + cnt); } } dp[1] = dp[0]; } if(-q<=m && m <= q && dp[1][m+q] != -1) cout << dp[1][m+q] + a[n]; else cout << "impossible"; return 0; }

Compilation message (stderr)

vault.cpp: In function 'int main()':
vault.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i = 0; i < a.size(); i ++)
      |                    ~~^~~~~~~~~~
vault.cpp:12:15: warning: unused variable 'res' [-Wunused-variable]
   12 |     int n, m, res = -1;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...