Submission #139366

# Submission time Handle Problem Language Result Execution time Memory
139366 2019-07-31T15:20:00 Z Boxworld Sails (IOI07_sails) C++14
40 / 100
1000 ms 6296 KB
#include <bits/stdc++.h>
using namespace std;
const int maxN=100100;
pair<int,int> a[maxN];
multiset<int> S;
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++){
		queue<int> Q;
		for (int j=tmp;j<=a[i].first;j++)S.insert(0);
		for (int j=0;j<a[i].second;j++){
			auto P=S.begin();
			Q.push(*P+1);
			S.erase(P);
		}
		for (int j=0;j<a[i].second;j++){
			S.insert(Q.front());
			Q.pop();
		}
		tmp=a[i].first+1;
	}
	long long ans=0;
	for (int i=0;i<a[n-1].first;i++){
		auto P=S.begin();
		int x=*P;
		ans+=x*(x-1)/2;
		S.erase(P);
	}
	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: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 364 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 256 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 3 ms 376 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 457 ms 676 KB Output is correct
2 Correct 426 ms 5148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 1276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 1360 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 1808 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 6296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 2388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 3072 KB Time limit exceeded
2 Halted 0 ms 0 KB -