Submission #721841

#TimeUsernameProblemLanguageResultExecution timeMemory
721841OttincaMUplifting Excursion (BOI22_vault)C++17
0 / 100
5066 ms2992 KiB
#include <iostream> #include <vector> #include "stdio.h" #include <map> using namespace std; // #define int long long long long const LLINF = 2e9 + 1; int const N = 4000000; int const ZER = 1000000; signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #ifdef WTF freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("error.txt", "w", stderr); #endif int m, l; cin >> m >> l; int smn = 0, smf = 0; vector <int> a(2 * m + 2), x, y, z; for(int i = 1; i <= 2 * m + 1; i ++){ cin >> a[i]; int K = a[i]; while(K --){ if(i - 1 - m > 0){ x.push_back(i - 1 - m); smn += i - 1 - m; } else if(i - 1 - m < 0){ y.push_back(i - 1 - m); smf += i - 1 - m; } else { z.push_back(i - 1 - m); } } } if(l > smn || l < smf){ cout << "impossible\n"; return 0; } map <int, int> dp; dp[0] = (int)z.size(); for(int t: x){ vector <int> id; for(auto p: dp) id.push_back(p.first); // cout << id.size() << "\n"; for(int i = id.size() - 1; i >= 0; i --){ dp[id[i] + t] = max(dp[id[i] + t], dp[id[i]] + 1); // cout << id[i] + t << " " << dp[id[i] + t] << "\n"; } } for(int t: y){ vector <int> id; for(auto p: dp) id.push_back(p.first); for(int i = 0; i < id.size(); i ++){ dp[id[i] + t] = max(dp[id[i] + t], dp[id[i]] + 1); } } if(dp.find(l) == dp.end()){ cout << "impossible\n"; } else { cout << dp[l] << "\n"; } return 0; }

Compilation message (stderr)

vault.cpp: In function 'int main()':
vault.cpp:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int i = 0; i < id.size(); i ++){
      |                        ~~^~~~~~~~~~~
#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...