Belarus @ 2019-09-08 20:47:40
严谨的二分法查找
竟然只有1AC,还有WA和TLE
就算是从l到r搜一遍时间复杂度也是O(n)啊
而n<=1e6啊
//p2801
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+9;
typedef long long ll;
int n,q;
ll a[maxn],b[maxn];
inline ll search(ll lft,ll rt,ll exp){
ll tot=0;
while(lft<rt){
ll mid=(lft+rt)>>1;
if(b[mid]>=exp) rt=mid;
else{
lft=mid+1;
tot=n-lft+1;
break;
}
}
return tot;
}
int main(){
ios::sync_with_stdio(0);
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>a[i];
b[i]=a[i];
}
while(q--){
ll l=0,r=0,c=0,w=0;
char ch;
cin>>ch;
if(ch=='A'){
cin>>l>>r>>c;
memcpy(b,a,sizeof(b));
sort(b+1,b+n+1);
cout<<search(l,r,c)<<endl;
}
else if(ch=='M'){
cin>>l>>r>>w;
for(int i=l;i<=r;i++) a[i]+=w;
}
}
return 0;
}
by Belarus @ 2019-09-08 22:16:40
@Polaris_Dane dalao太巨了
by Belarus @ 2019-09-08 22:19:27
@只以 等一下,我好像没意识到难度是省选QwQ
by Belarus @ 2019-09-08 22:27:15
我枯了
我太难了
我放弃了
QwQ