Submission #579730

#TimeUsernameProblemLanguageResultExecution timeMemory
579730wdjpngUplifting Excursion (BOI22_vault)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define int long long #define rep(i,n) for(int i = 0; i < n; i++) #define per(i,n) for(int i = n-1; i >=0; i--) // #pragma GCC optimize("O3") // #pragma optimize("sse,sse2,sse3,sse4,avx,avx2") using namespace std; signed main() { int m,l; cin>>m>>l; int maxl=(m)*(m+1)/2*100; //TODO change to 100 if(l>maxl) {cout<<"impossible\n"; exit(0);} vector<int>dp(2*maxl, -1); dp[maxl]=0; vector<int>in(2*m+1); rep(i,2*m+1) cin>>in[i]; for(int cll = m; cll >=0; cll--) { int cl = cll; int a = in[m+cl]; rep(whatever,a) { for(int j = cl*(cl+1)/2*100; j >= -cl*(cl+1)/2*100; j--) { int i = j+m; if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue; dp[i]=max(dp[i], dp[i-cl]+1); } } if(cl==0) continue; a=in[m-cl]; int oldcl; cl=-cl; rep(whatever,a) { for(int j = -oldcl*(oldcl+1)/2*100; j <= oldcl*(oldcl+1)/2*100; j++) { int i = j+m; if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue; dp[i]=max(dp[i], dp[i-cl]+1); } } } if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n'; else cout<<"impossible\n"; }

Compilation message (stderr)

vault.cpp: In function 'int main()':
vault.cpp:32:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                     if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                                ~~~~^~~~~~~~~~~
vault.cpp:46:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |                 if(i-cl<0||i-cl>=dp.size()||dp[i-cl]==-1) continue;
      |                            ~~~~^~~~~~~~~~~
vault.cpp:54:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     if(l+maxl<dp.size()&&dp[l+maxl]>0) cout<<dp[l+maxl]<<'\n';
      |        ~~~~~~^~~~~~~~~~
vault.cpp:39:13: warning: 'oldcl' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |         int oldcl;
      |             ^~~~~
#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...