Submission #139530

# Submission time Handle Problem Language Result Execution time Memory
139530 2019-08-01T00:33:17 Z Boxworld Sails (IOI07_sails) C++14
15 / 100
1000 ms 2948 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++){
		memset(L,0,sizeof(L));
		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];
		tmp=a[i].first;
	}
	long long ans=0;
	for (int i=0;i<=a[n-1].first;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 760 KB Output is correct
2 Incorrect 2 ms 760 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 760 KB Output is correct
2 Correct 14 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1612 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1082 ms 1784 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 2948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 2940 KB Time limit exceeded
2 Halted 0 ms 0 KB -