Submission #139533

# Submission time Handle Problem Language Result Execution time Memory
139533 2019-08-01T00:42:31 Z Boxworld Sails (IOI07_sails) C++14
30 / 100
1000 ms 1784 KB
#include <bits/stdc++.h>
using namespace std;
const int N=100010;
pair<int,int> a[N];
int s[N],L[N];
int main(){
	int n,tmp=0,MX=0;
	scanf("%d",&n);
	for (int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
	sort(a,a+n); 
	for (int i=0;i<n;i++){
		s[0]+=a[i].first-tmp;
		int cnt=a[i].second;
		for (int j=0;j<=MX;j++)
		if (cnt>s[j]){
			L[j+1]=s[j];
			cnt-=s[j];
			s[j]=0;
		}else{
			L[j+1]=cnt;
			s[j]-=cnt;
			cnt=0;
			break;
		}
		if (L[MX+1]>0)MX++;
		for (int j=0;j<=MX;j++)s[j]+=L[j],L[j]=0;
		tmp=a[i].first;
	}
	long long ans=0;
	for (int i=0;i<=n;i++)ans+=s[i]*i*(i-1)/2;
	printf("%lld\n",ans);
	return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
sails.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 1208 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 840 ms 1416 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 1656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 1784 KB Time limit exceeded
2 Halted 0 ms 0 KB -