Submission #50521

# Submission time Handle Problem Language Result Execution time Memory
50521 2018-06-11T10:28:26 Z Yusup01 K blocks (IZhO14_blocks) C++17
0 / 100
1000 ms 1276 KB
#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()
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 1276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1276 KB Time limit exceeded
2 Halted 0 ms 0 KB -