Submission #777551

# Submission time Handle Problem Language Result Execution time Memory
777551 2023-07-09T10:25:41 Z a_aguilo Sails (IOI07_sails) C++14
40 / 100
1000 ms 2476 KB
#include<bits/stdc++.h>

using namespace std;

int N;
long long ans;
const int maxN = 100002;
const int maxH = 100002;
pair<int, int> masts[maxN];

int main(){
	ans = 0;
	cin >> N;
	for(int i = 0; i < N; ++i) cin >> masts[i].first >> masts[i].second;
	priority_queue<int> PQ;
	sort(masts, masts+N);
	for(int i = 0; i < N; ++i){
		int h = masts[i].first;
		int k = masts[i].second;
		queue<int> sails;
		while(PQ.size() < h)PQ.push(0);
		for(int j = 0; j < k; ++j){
			int pos = -PQ.top(); PQ.pop();
			sails.push(pos+1);
			ans += pos;
		}
		while(!sails.empty()){
			PQ.push(-sails.front()); sails.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:21:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |   while(PQ.size() < h)PQ.push(0);
      |         ~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 170 ms 348 KB Output is correct
2 Correct 148 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 1388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 2476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 2164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 2324 KB Time limit exceeded
2 Halted 0 ms 0 KB -