// Author: Kajetan Ramsza
#include "bits/stdc++.h"
using namespace std;
template<typename F, typename S> ostream& operator<<(ostream& os, const pair<F, S> &p) { return os<<"("<<p.first<<", "<<p.second<<")"; }
template<typename T> ostream &operator<<(ostream & os, const vector<T> &v) { os << "{"; typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) { if( it != v.begin() ) os << ", "; os << *it; } return os << "}"; }
void dbg_out() { cerr<<'\n'; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr<<' '<<H; dbg_out(T...); }
#ifdef DEBUG
#define dbg(...) cerr<<"(" << #__VA_ARGS__ <<"):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
typedef long long ll;
const int inf = 1e9 + 7;
int n,q;
vector<int> vec;
int find(int x) {
int b = 0, e = n;
while(b < e) {
int mid = (b + e) / 2;
if(vec[mid] < x) {
b = mid + 1;
} else {
e = mid;
}
}
return b;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>q;
vec.resize(n);
for(auto &v : vec)
cin>>v;
vec.push_back(inf);
sort(vec.begin(), vec.end());
for(int i=0;i<q;i++) {
dbg(vec);
char query;
cin>>query;
if(query == 'F') {
int c, h;
cin>>c>>h;
sort(vec.begin(), vec.end());
int ind = 0;
for(int j=0;j<n;j++) {
if(vec[j] >= h) {
ind++;
vec[j]++;
if(ind == c) break;
}
}
sort(vec.begin(), vec.end());
} else {
int mini, maxi;
cin>>mini>>maxi;
int ind1 = find(mini);
int ind2 = find(maxi);
if(vec[ind2] > maxi) ind2--;
cout<<ind2 - ind1 + 1<<'\n';
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
1492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1008 ms |
1652 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1036 ms |
1892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
1232 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
1364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
1236 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1092 ms |
1676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
1492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
2212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |