#include<iostream>
#include<algorithm>
#define int int64_t
using namespace std;
const int N=1e5+7;
int a[N],n,q;
void order(int c,int h)
{
int d=c,s=0,x=-1,p=1e18;
for(int i=0;i<n&&d;i++)
{
if(a[i]>=h)
{
if(p==1e18) p=i;
if(i==0) s=1,x=a[i];
else if(a[i]!=a[i-1]) s=1,x=a[i];
else s++;
d--;
}
}
d=c;
for(int i=n-1;i>=0&&i>=p;i--)
{
if(a[i]==x&&s) a[i]++,s--,d--;
else if(a[i]!=x&&d<c) a[i]++,d--;
}
}
signed main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>q;
for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
while(q--)
{
char ty; cin>>ty;
if(ty=='F')
{
int c,h; cin>>c>>h;
order(c,h);
}
else{
int mn,mx; cin>>mn>>mx;
int p1=lower_bound(a,a+n,mn)-a;
int p2=upper_bound(a,a+n,mx)-a;
cout<<p2-p1<<endl;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
1676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
488 KB |
Output is correct |
3 |
Correct |
5 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
128 ms |
612 KB |
Output is correct |
6 |
Correct |
169 ms |
748 KB |
Output is correct |
7 |
Correct |
21 ms |
348 KB |
Output is correct |
8 |
Correct |
102 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
175 ms |
848 KB |
Output is correct |
2 |
Correct |
225 ms |
784 KB |
Output is correct |
3 |
Correct |
16 ms |
344 KB |
Output is correct |
4 |
Correct |
117 ms |
988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
231 ms |
848 KB |
Output is correct |
2 |
Correct |
185 ms |
820 KB |
Output is correct |
3 |
Correct |
87 ms |
348 KB |
Output is correct |
4 |
Correct |
195 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1096 ms |
1504 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1036 ms |
1568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1055 ms |
1860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1053 ms |
1916 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1020 ms |
1828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
341 ms |
3408 KB |
Output is correct |