This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |