#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
blocks.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1083 ms |
1172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1078 ms |
1172 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |