Submission #138523

# Submission time Handle Problem Language Result Execution time Memory
138523 2019-07-30T06:09:48 Z Boxworld Sails (IOI07_sails) C++14
40 / 100
1000 ms 3280 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int maxN=100100;
pii a[maxN];
int s[maxN];
priority_queue<pii,vector<pii>,greater<pii> > Q;
queue<int> Q1;
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
	sort(a,a+n);
	int tmp=1;
	for(int i=0;i<n;i++){
		for (int j=tmp;j<=a[i].first;j++)Q.push(make_pair(0,j));
		for (int j=0;j<a[i].second;j++){
			pii P=Q.top();Q.pop();
			s[P.second]++;
			Q1.push(P.second);
		}
		while(!Q1.empty()){
			int x=Q1.front();Q1.pop();
			Q.push(make_pair(s[x],x));
		}
		tmp=a[i].first+1;
	}
	long long ans=0;
	for (int i=1;i<tmp;i++)ans+=s[i]*(s[i]-1)/2;
	printf("%lld\n",ans);
	return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
sails.cpp:12:27: 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 17 ms 388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 459 ms 504 KB Output is correct
2 Correct 392 ms 1784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 1036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 1152 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 1468 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 3280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 2348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 2688 KB Time limit exceeded
2 Halted 0 ms 0 KB -