Submission #531039

# Submission time Handle Problem Language Result Execution time Memory
531039 2022-02-27T13:02:42 Z xuliu Growing Trees (BOI11_grow) C++17
20 / 100
1000 ms 1832 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long 
#define ld long double 
#define debug if(0)

const int mod = 1e9 + 7;
const ll infL = 1e18 + 7;
const int inf = 1e9 + 7;

void add(int &a, int b) { a = (a+b)%mod; }
int add(int a, int b, int c) { int res = (((a+b)%mod) + c)%mod; return res; }

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, m; cin>>n>>m;
	vector<int> tr(n);
	for(int i=0; i<n; i++) {
		cin>>tr[i];
	}
	sort(tr.begin(), tr.end());
	debug {
		for(int i=0; i<n; i++) cerr<<tr[i]<<" ";
		cerr<<"\n";
	}
	while(m--) {
		char t; cin>>t;
		if(t == 'F') {
			int c, h; cin>>c>>h;
			int cnt = 0;
			for(int i=0; i<n; i++) {
				if(tr[i] >= h && cnt < c) {
					tr[i]++;
					cnt++;
					if(cnt > c) break;
				}
			}
			sort(tr.begin(), tr.end());
			debug {
				cerr<<"F "<<c<<" "<<h<<"\n";
				for(int i=0; i<n; i++) cerr<<tr[i]<<" ";
				cerr<<"\n";
			}
		}
		else {
			int a, b; cin>>a>>b;
			int ans = 0;
			for(int i=0; i<n; i++) {
				if(tr[i] > b) break;
				if(tr[i] >= a) ans++;
			}
			cout<<ans<<"\n";
		}
	}
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 5 ms 328 KB Output is correct
4 Correct 4 ms 324 KB Output is correct
5 Correct 487 ms 1304 KB Output is correct
6 Correct 545 ms 1832 KB Output is correct
7 Correct 230 ms 332 KB Output is correct
8 Correct 163 ms 1052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 914 ms 804 KB Output is correct
2 Correct 882 ms 1676 KB Output is correct
3 Correct 46 ms 348 KB Output is correct
4 Correct 167 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 632 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 676 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 724 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 944 KB Time limit exceeded
2 Halted 0 ms 0 KB -