Submission #834782

# Submission time Handle Problem Language Result Execution time Memory
834782 2023-08-22T19:20:27 Z mat_jur Growing Trees (BOI11_grow) C++17
0 / 100
1000 ms 8276 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

int main () {
	int n, q;
	cin >> n >> q;
	vector<int> cnt(1000000);
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	while (q--) {
		char c;
		cin >> c;
		if (c == 'F') {
			int c, h;
			cin >> c >> h;
			while (c > 0) {
				int x = min(cnt[h], c);
				cnt[h] -= x;
				cnt[h+1] += x;
				c -= x;
				h++;
			}
		}
		else {
			int res = 0;
			int l, r;
			cin >> l >> r;
			for (int i = l; i <= r; i++) {
				res += cnt[i];
			}
			cout << res << '\n';
		}
	}

	return 0;
}

# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 8276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 24 ms 8276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 9 ms 8276 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 157 ms 4276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 512 ms 4300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 4180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 8268 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 846 ms 4480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 4556 KB Time limit exceeded
2 Halted 0 ms 0 KB -