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>
#define ll long long
#define endl "\n"
using namespace std;
const ll mod = 1e9 + 7;
const int N = 1e5 + 5;
int n, q;
int val[100005];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i ++ )
cin >> val[i];
sort(val + 1, val + n + 1);
while (q -- ){
char type;
int a, b;
cin >> type >> a >> b;
if (type == 'F'){
int pos = lower_bound(val + 1, val + n + 1, b) - val;
for (int i = pos; i <= min(n, pos + a - 1); i ++ )
val[i] ++;
sort(val + 1, val + n + 1);
}
else {
int pos1 = upper_bound(val + 1, val + n + 1, b) - val;
int pos2 = lower_bound(val + 1, val + n + 1, a) - val;
cout << pos1 - pos2 <<endl;
}
}
}
# | 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... |