Submission #649855

# Submission time Handle Problem Language Result Execution time Memory
649855 2022-10-11T12:52:43 Z rsjw Growing Trees (BOI11_grow) C++17
0 / 100
1000 ms 3532 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n;
int t[100010],a[100010];
void update(int x,int I) {
	while(x<=n) t[x]+=I,x+=x&-x;
}
int query(int x) {
	int ans=0; while(x) ans+=t[x],x-=x&-x; return ans;
}
//写个假的二分
int search_lower(int x) { //第一个大于等于x 
	int l=1,r=n,mid;
	while(l<=r) {
		mid=(l+r)/2;
		if(query(mid)<x) l=mid+1;
		else r=mid-1;
	}
	return r+1;
}
int search_upper(int x) { //第一个大于x 
	int l=1,r=n,mid;
	while(l<=r) {
		mid=(l+r)/2;
		if(query(mid)<=x) l=mid+1;
		else r=mid-1;
	}
	return r+1;
}
signed main() {
	int m,i;
	char c;
	int x,y,t,t2;
	cin>>n>>m;
	for(i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++) update(i,a[i]-a[i-1]);
	for(i=1;i<=m;i++) {
		cin>>c>>x>>y;
		if(c=='F') {
			t=search_lower(y);
			update(t,1);
			update(t+x-1,-1);
			t2=search_upper(query(t+x-1))-1;
			update(t2,1);
			update(t2+1,-1);
		} else cout<<search_upper(y)-search_lower(x)<<endl;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 3120 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1063 ms 1236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 2900 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 1548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 3144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 54 ms 3120 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 3532 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -