Submission #138601

# Submission time Handle Problem Language Result Execution time Memory
138601 2019-07-30T07:15:33 Z 20160161simone Sails (IOI07_sails) C++14
30 / 100
1000 ms 4216 KB
#include <bits/stdc++.h>
#define N 100000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll read()
{
	char c=getchar();bool flag=0;ll x=0;
	while(c<'0'||c>'9'){if(c=='-')flag=1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return flag?-x:x;
}
struct gan{
	ll h,s;
}a[N];
struct ceng{
	ll num,val,sum;
}b[N];
bool cmp(gan a,gan b)
{
	if(a.h<b.h) return 1;
	return 0;
}
bool cmp2(ceng a,ceng b)
{
	if(a.val<b.val) return 1;
	return 0; 
}
ll n,mx;
int main()
{
	n=read(),mx=0;
	for(ll i=1;i<=n;i++)
	{
		a[i].h=read(),a[i].s=read();
		mx=max(mx,a[i].h); 
	} 
	for(ll i=1;i<=mx;i++) b[i].num=i;
	sort(a+1,a+1+n,cmp);
	for(ll i=1;i<=n;i++)
	{
		sort(b+1,b+1+a[i].h,cmp2); 
		for(ll j=1;j<=a[i].s;j++) b[j].val++,b[j].sum+=(b[j].val-1);
	}
	ll ans=0;
	//for(ll i=1;i<=mx;i++) printf("%lld::%lld\n",b[i].num,b[i].val);
	for(ll i=1;i<=mx;i++) ans+=b[i].sum;
	printf("%lld",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 17 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 750 ms 504 KB Output is correct
2 Execution timed out 1077 ms 2680 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 1528 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 2296 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 3832 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 4216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 4216 KB Time limit exceeded
2 Halted 0 ms 0 KB -