#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;
int y = 0;
while (c > 0) {
int x = min(cnt[h], c);
cnt[h] += y;
cnt[h] -= x;
y = x;
c -= x;
h++;
}
cnt[h] += y;
}
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 |
8268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4180 KB |
Output is correct |
2 |
Correct |
7 ms |
4280 KB |
Output is correct |
3 |
Runtime error |
9 ms |
8428 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
8340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
8376 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
8316 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
8324 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
18 ms |
8324 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
24 ms |
8312 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
27 ms |
8244 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
8272 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |