| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1257050 | terracottalite | Growing Trees (BOI11_grow) | C++20 | 85 ms | 1676 KiB | 
#include <stdio.h>
#include <algorithm>
using namespace std;
const int N = 100005;
int n, m;
int b[N] = { 0 };
int a[N] = { 0 };
void update(int p, int v) {
	while (p <= n) {
		b[p] += v;
		p += p&-p;
	}
}
int query(int r) {
	r = min(r, n);
	int res = 0;
	while (r > 0) {
		res += b[r];
		r -= r&-r;
	}
	return res;
}
int bs(int h) {
	int l = 0;
	int r = n+1;
	while (r-l>1) {
		int m = (l+r)/2;
		if (query(m) < h) {
			l = m;
		} else {
			r = m;
		}
	}
	return r;
}
int main()
{
	scanf("%d %d", &n, &m);
	for (int i=1;i<=n;i++) {
		scanf("%d", &a[i]);
	}
	sort(a+1, a+n+1);
	for (int i=1;i<=n;i++) {
		update(i, a[i]-a[i-1]);
	}
	/*
	map<int, int> mp;
	for (int i=n;i>0;i--) {
		mp[a[i]] = i;
	}
	*/
	char ty[4];
	while (m--) {
		scanf("%s", ty);
		if (ty[0] == 'F') {
			int c, h;
			scanf("%d %d", &c, &h);
			int r = bs(h);
			int lm = bs(query(r+c)+1)-1;
			int nm = bs(query(r+c));
			int nc = c-(nm-r);
			if (r+c > n) {
				update(r, 1);
				continue;
			}
			if (query(r) != query(r+c)) {
				update(r, 1);
				update(nm, -1);
			}
			update(lm+1, -1);
			update(lm-nc+1, 1);
			//printf("%d %d %d %d\n", r ,lm ,nm, nc);
			/*
			putchar('x');
			for (int i=1;i<=n;i++) {
				printf(" %d", query(i));
			}
			putchar('\n');
			*/
		} else {
			int l, r;
			scanf("%d %d", &l, &r);
			printf("%d\n", bs(r+1) - bs(l));
		}
	}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
