답안 #1116630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116630 2024-11-22T02:52:47 Z Bzslayed Exhibition (JOI19_ho_t2) C++17
100 / 100
47 ms 7112 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define coutpair(p) cout << p.first << " " << p.second << "|"

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

//greedy idea : put the largest value picture that can fit into the ith frame, starting from the largest frame.
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n, m; cin >> n >> m;
    priority_queue<pll> pq; //{value, size}
    for (int i=0; i<n; i++){
		ll s, v; cin >> s >> v;
		pq.push({v, s});
	}
    ll c[m];
    for (int i=0; i<m; i++) cin >> c[i];
    
    sort(c, c+m, greater<ll>());
    
    ll val[m];
    for (int i=0; i<m; i++){
		while (c[i] < pq.top().second && !pq.empty()) pq.pop();
		if (pq.empty()){
			cout << i;
			return 0;
		}
		val[i] = pq.top().first; pq.pop();
		
		
		if (i == 0) continue;
		
		if (val[i] > val[i-1]){
			cout << i;
			return 0;
		}
	}
	
	cout << m;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 524 KB Output is correct
31 Correct 1 ms 508 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 504 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 2 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 524 KB Output is correct
31 Correct 1 ms 508 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 336 KB Output is correct
34 Correct 1 ms 336 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 508 KB Output is correct
38 Correct 40 ms 7080 KB Output is correct
39 Correct 43 ms 6860 KB Output is correct
40 Correct 38 ms 6960 KB Output is correct
41 Correct 41 ms 6848 KB Output is correct
42 Correct 40 ms 6868 KB Output is correct
43 Correct 40 ms 6856 KB Output is correct
44 Correct 40 ms 6848 KB Output is correct
45 Correct 40 ms 6980 KB Output is correct
46 Correct 40 ms 6848 KB Output is correct
47 Correct 37 ms 6240 KB Output is correct
48 Correct 36 ms 6256 KB Output is correct
49 Correct 33 ms 6344 KB Output is correct
50 Correct 35 ms 6344 KB Output is correct
51 Correct 43 ms 7112 KB Output is correct
52 Correct 42 ms 6848 KB Output is correct
53 Correct 43 ms 6968 KB Output is correct
54 Correct 43 ms 7104 KB Output is correct
55 Correct 42 ms 7112 KB Output is correct
56 Correct 19 ms 5068 KB Output is correct
57 Correct 22 ms 2768 KB Output is correct
58 Correct 18 ms 4960 KB Output is correct
59 Correct 21 ms 5236 KB Output is correct
60 Correct 14 ms 2896 KB Output is correct
61 Correct 24 ms 4300 KB Output is correct
62 Correct 45 ms 6852 KB Output is correct
63 Correct 45 ms 6984 KB Output is correct
64 Correct 47 ms 6644 KB Output is correct
65 Correct 43 ms 6848 KB Output is correct
66 Correct 43 ms 6856 KB Output is correct
67 Correct 44 ms 7036 KB Output is correct
68 Correct 44 ms 6848 KB Output is correct
69 Correct 42 ms 6848 KB Output is correct
70 Correct 44 ms 7084 KB Output is correct
71 Correct 47 ms 6992 KB Output is correct
72 Correct 45 ms 7104 KB Output is correct
73 Correct 39 ms 7112 KB Output is correct