Submission #835106

# Submission time Handle Problem Language Result Execution time Memory
835106 2023-08-23T08:27:11 Z mat_jur Sails (IOI07_sails) C++14
15 / 100
83 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << ", " << p.second << ")"; return o;}
auto operator<<(auto &o, auto x)->decltype(x.end(), o) {o<<"{"; for(auto e : x) o<<e<<", "; return o<<"}";}
#define debug(X) cerr << "["#X"]: " << X << '\n';
#else 
#define debug(X) ;
#endif
#define ll long long
#define all(v) (v).begin(), (v).end()

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	vector<int> h(n), k(n);
	ll s = 0;
	int mxH = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i] >> k[i];
		mxH = max(mxH, h[i]);
		s += k[i];
	}
	vector<int> cnt(n);
	vector<queue<int>> q(mxH);
	for (int i = n-1; i >= 0; i--) {
		for (int j = 0; j < h[i]; j++) q[j].push(i);	
	}
	ll res = 0;
	int x = 0;
	while(s > 0) {
		for (int i = mxH-1; i >= 0; i--) {
			while(!q[i].empty() && cnt[q[i].front()] >= k[q[i].front()]) q[i].pop();
			if (q[i].empty()) continue;
			cnt[q[i].front()]++;
			res += x;
			q[i].pop();
			s--;
		}
		x++;
	}
	cout << res << '\n';

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 23904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 79 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 73 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 41 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -