답안 #522082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522082 2022-02-03T19:17:52 Z sidon Matryoshka (JOI16_matryoshka) C++17
100 / 100
196 ms 12616 KB
#include <bits/stdc++.h>
using namespace std;

int N, Q, INF = 2e9;

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> Q;
	array<int, 2> a[N], _;
	vector<array<int, 2>> qAt[N]; // post-processing

	for(auto &[r, h] : a)
		cin >> r >> h, r = -r;

	sort(a, a+N);

	int res[Q] = {};
	for(int i = 0; i < Q; ++i) {
		int A, B; cin >> A >> B;

		if(a[0][0] <= -A)
			qAt[lower_bound(a, a+N, _={-A, INF}) - a - 1].push_back({B, i});
	}

	vector<int> b;

	for(int i = 0; i < N; ++i) {
		int v = a[i][1];
		if(!i || b.back() <= v) b.push_back(v);
		else *upper_bound(begin(b), end(b), v) = v;

		for(auto &[w, qI] : qAt[i])
			res[qI] = upper_bound(begin(b), end(b), w) - begin(b);
	}

	for(int &i : res) cout << i << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 448 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 452 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 444 KB Output is correct
29 Correct 3 ms 452 KB Output is correct
30 Correct 1 ms 392 KB Output is correct
31 Correct 2 ms 448 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 428 KB Output is correct
35 Correct 2 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 0 ms 312 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 316 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 2 ms 448 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 452 KB Output is correct
26 Correct 2 ms 460 KB Output is correct
27 Correct 2 ms 460 KB Output is correct
28 Correct 2 ms 444 KB Output is correct
29 Correct 3 ms 452 KB Output is correct
30 Correct 1 ms 392 KB Output is correct
31 Correct 2 ms 448 KB Output is correct
32 Correct 2 ms 460 KB Output is correct
33 Correct 2 ms 460 KB Output is correct
34 Correct 2 ms 428 KB Output is correct
35 Correct 2 ms 444 KB Output is correct
36 Correct 183 ms 12260 KB Output is correct
37 Correct 172 ms 12440 KB Output is correct
38 Correct 53 ms 5188 KB Output is correct
39 Correct 124 ms 10596 KB Output is correct
40 Correct 144 ms 11332 KB Output is correct
41 Correct 182 ms 12308 KB Output is correct
42 Correct 97 ms 11044 KB Output is correct
43 Correct 73 ms 12616 KB Output is correct
44 Correct 188 ms 12472 KB Output is correct
45 Correct 193 ms 12320 KB Output is correct
46 Correct 196 ms 12416 KB Output is correct
47 Correct 177 ms 12028 KB Output is correct
48 Correct 182 ms 12568 KB Output is correct
49 Correct 189 ms 12056 KB Output is correct
50 Correct 191 ms 12564 KB Output is correct