This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back
using namespace std;
long long i,j,n,k,jem,mx,ans,l;
vector<long long>gr;
vector<long long>gr1;
main()
{
cin>>n>>k;
long long 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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |