이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |