Submission #516248

# Submission time Handle Problem Language Result Execution time Memory
516248 2022-01-20T20:07:36 Z thomas_li Exhibition (JOI19_ho_t2) C++17
50 / 100
1000 ms 4896 KB
#include <bits/stdc++.h>
using namespace std;
const int MM = 1e5+5;
int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n,m,ans = 0; cin >> n >> m;
	vector<array<int,2>> a; vector<int> b;
	for(int i = 0; i < n; i++){
		int s,v; cin >> s >> v;
		a.push_back({s,v});
	}
	for(int i = 0; i < m; i++){
		int c; cin >> c;
		b.emplace_back(c);
	}
	sort(b.begin(),b.end());
	sort(a.begin(),a.end());
	auto solve = [&](int st){
		priority_queue<int,vector<int>,greater<>> q;	
		for(int i = st, j = 0,lst = 0; i < m; i++){
			while(j < n && a[j][0] <= b[i]){
				if(lst <= a[j][1]) q.push(a[j][1]);
				j++;
			}
			if(q.empty()) return 0;
			lst = q.top();
			q.pop();
		}
		return 1;
	};
	for(int i = 0; i < m; i++){
		if(solve(i)){
			cout << m-i << "\n";
			return 0;
		}
	}
	cout << "0\n";
}
// if ans = k, we should take k biggest frames
// we should put min value that fits in left frame, min value that fits into second left, ...

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:6:10: warning: unused variable 'ans' [-Wunused-variable]
    6 |  int n,m,ans = 0; cin >> n >> m;
      |          ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 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 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 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 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 2 ms 320 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 7 ms 320 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 10 ms 332 KB Output is correct
37 Correct 11 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 316 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 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 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 2 ms 320 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 324 KB Output is correct
27 Correct 1 ms 356 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 7 ms 320 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 320 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 10 ms 332 KB Output is correct
37 Correct 11 ms 356 KB Output is correct
38 Correct 44 ms 4796 KB Output is correct
39 Correct 44 ms 4896 KB Output is correct
40 Correct 51 ms 4892 KB Output is correct
41 Correct 48 ms 4836 KB Output is correct
42 Correct 50 ms 4812 KB Output is correct
43 Correct 45 ms 4784 KB Output is correct
44 Execution timed out 1004 ms 4800 KB Time limit exceeded
45 Halted 0 ms 0 KB -