Submission #50525

#TimeUsernameProblemLanguageResultExecution timeMemory
50525MrPlanyK blocks (IZhO14_blocks)C++17
0 / 100
1075 ms1256 KiB
#include<bits/stdc++.h> #define pb push_back #define pp pop_back using namespace std; int i,j,n,k,jem,mx,ans,l; vector<int>gr; vector<int>gr1; main() { cin>>n>>k; int b[n+1],a[k+1]; for(i=1; i<=n; i++) cin>>b[i]; fill(a+1,a+1+k,1); a[0]=1; for(;;) { mx=0; for(i=1; i<=k; i++) jem+=a[i]; if(jem==n) { for(i=1; i<=k; i++) { for(j=l; j<l+a[i]; j++) mx=max(mx,b[j]); l+=a[i]; gr.pb(mx); mx=0; } for(auto to:gr) ans+=to; gr1.pb(ans); gr.erase(gr.begin(),gr.end()); ans=0; } jem=0; l=1; for(i=1; i<=k; i++) { if(a[i]==n-k+1) a[i]=1; else {a[i]++; break;} } if(i==k+1) break; } sort(gr1.begin(),gr1.end()); cout<<gr1[0]; return 0; }

Compilation message (stderr)

blocks.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...