Submission #900150

# Submission time Handle Problem Language Result Execution time Memory
900150 2024-01-07T18:29:42 Z Abdalaziz_Alshami Growing Trees (BOI11_grow) C++17
0 / 100
200 ms 2204 KB
#include<iostream>
#include<algorithm>
#define int int64_t
using namespace std;
const int N=7e3+7;
int a[N],n,q;
void order(int c,int h)
{
	int d=c,s=0;
	char x='*';
	for(int i=0;i<n&&d;i++)
	{
		if(a[i]>=h)
		{
			if(a[i]!=a[i-1]) s=1,x=a[i];
			else s++;
			d--;
		}
	}
	d=c;
	for(int i=n-1;i>=0&&d;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 Runtime error 1 ms 600 KB Execution killed with signal 11
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 508 KB Output is correct
3 Incorrect 6 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 169 ms 2204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 200 ms 1556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -