#include <bits/stdc++.h>
#define int long long
#define all(v) v.begin(),v.end()
#define keepUnique(a) sort(all(a));v.erase(unique(all(v)),v.end())
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(a) cout << #a << " = " << a << endl;
using namespace std;
const int N = 100000;
int ara[N],temp[N];
int32_t main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n,m,c,h;
cin >> n >> m;
for(int i = 0; i < n;i++){
cin >> ara[i];
}
sort(ara,ara+n);
char ch;
while(m--){
cin >> ch;
if(ch == 'F'){
//cout << "hola\n";
cin >> c >> h;
int pos = 0;
int lower = lower_bound(ara,ara+n,h)-ara;
// cout << ara[lower] << " " << h << endl;
debug(lower);
for (int i = lower; i < n and i < lower+c; i++){
ara[i]++;
temp[pos++] = ara[i];
}
int k = pos;
int j = min(n,lower+c);
int i = 0;
pos = lower;
for(;;){
if(pos == n)break;
else if(j == n)ara[pos++] = temp[i++];
else if(i == k)ara[pos++] = ara[j++];
else if(temp[i] < ara[j]){
ara[pos++] = temp[i++];
}
else ara[pos++] = ara[j++];
}
//for(i = 0; i < n;i++){
// cout << ara[i] << " ";
//}cout << endl;
}
else{
cin >> c >> h;
int lower = lower_bound(ara,ara+n,c)-ara;
int upper = upper_bound(ara,ara+n,h)-ara;
cout << upper-lower << endl;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
2044 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
254 ms |
1008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
271 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
1896 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
2016 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
2052 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1062 ms |
1940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1058 ms |
2156 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
374 ms |
2492 KB |
Output isn't correct |