Submission #991195

# Submission time Handle Problem Language Result Execution time Memory
991195 2024-06-01T14:37:07 Z goats_9 Sails (IOI07_sails) C++17
40 / 100
1000 ms 11804 KB
/* Author: goats_9 */

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vector<array<ll, 2>> a(n);
	for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
	sort(a.begin(), a.end());
	set<array<ll, 2>> st;
	int mxl = 0;
	for (int i = 0; i < n; i++) {
		while (mxl < a[i][0]) {
			st.insert({0, -mxl});
			mxl++;
		}
		int j = a[i][1];
		vector<array<ll, 2>> b;
		while (j--) {
			b.push_back(*st.begin());
			st.erase(st.begin());
		}
		for (auto br : b) {
			br[0]++;
			st.insert(br);
		}
	}
	ll ans = 0;
	for (auto [u, v] : st) ans += u*(u - 1)/2;
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB Output is correct
2 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 16 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 494 ms 836 KB Output is correct
2 Correct 427 ms 6920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1037 ms 1900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 1724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1081 ms 2328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1044 ms 11804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1012 ms 3416 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 4328 KB Time limit exceeded
2 Halted 0 ms 0 KB -