Submission #138729

# Submission time Handle Problem Language Result Execution time Memory
138729 2019-07-30T09:19:24 Z WongHokFong_cpp Sails (IOI07_sails) C++14
0 / 100
1000 ms 3904 KB
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <queue> 
using namespace std;
int n,h,k,height,mini,s,c;
struct smg
{
	int h,k;
}f[100001];
bool cmp(smg a,smg b)
{
	return a.h<b.h;
}
struct helo
{
	int flagged,num;
	bool operator < (const helo a) const
	{
		if (flagged==a.flagged) return num<a.num;
		else return flagged>a.flagged;
	} 
}pls[100001];
priority_queue <helo> q;
int main(void)
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		cin>>h>>k;height=max(h,height);f[i].h=h;f[i].k=k;
	}
	sort(f+1,f+n+1,cmp);
	for (int i=1;i<=height;i++)
	{
		q.push((helo){0,i});
	}
	for (int i=1;i<=n;i++)
	{
		for (int p=1;p<=f[i].k;p++)
		{
			helo cccccc=q.top();
			q.pop();
			c=1;pls[c]=cccccc;
			while (cccccc.num>f[i].h)
			{
				//cout<<"ES";
				c++;
				pls[c]=q.top();
				cccccc=q.top();
				q.pop();
			}
			cccccc.flagged++;
			//cout<<cccccc.flagged<<' ';
			q.push(cccccc);
			for (int xd=1;xd<=c-1;xd++) q.push(pls[xd]);
		}
		//cout<<endl<<endl;
	}
	for (int i=1;i<=height;i++) 
	{
		helo cc=q.top();
		q.pop();
		//cout<<cc.flagged<<' ';
		s+=(cc.flagged-1)*cc.flagged/2;
	}
	cout<<s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 296 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1050 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 1008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 1524 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 2160 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 3024 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 3772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 3904 KB Time limit exceeded
2 Halted 0 ms 0 KB -