답안 #878766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
878766 2023-11-25T07:44:01 Z niter Exhibition (JOI19_ho_t2) C++14
100 / 100
217 ms 7724 KB
#include <bits/stdc++.h>
#define pb push_back
#define ins isnert
#define pii pair<int,int>
#define ff first
#define ss second
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define ops(x) cerr << x;
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
#define BAE(x) (x).begin(), (x).end()
using namespace std;

const int mxn = (int)(1e5) + 10;
struct P{
    int sz, val;
    void read(){
        cin >> sz >> val;
    }
    bool operator<(P x){
        return sz < x.sz;
    }
}a[mxn];
int b[mxn];
vector<int> can_val[mxn];

bool check(int n, int m, int start){
    priority_queue<int, vector<int>, greater<int>> pq;
    int pre = -1;
    loop(i,1,start){
        for(auto &j:can_val[i]){
            pq.push(j);
        }
    }
    bool now_can;
    loop(i,start,m+1){
        now_can = false;
        for(auto &j:can_val[i]){
            pq.push(j);
        }
        while(!pq.empty()){
            if(pq.top() < pre) pq.pop();
            else{
                now_can = true;
                pre = pq.top();
                pq.pop();
                break;
            }
        }
        if(!now_can) return false;
    }
    return true;
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int n, m;
    cin >> n >> m;
    loop(i,1,n+1){
        a[i].read();
    }
    sort(a + 1, a + (n + 1));
    loop(i,1,m+1){
        cin >> b[i];
    }
    sort(b + 1, b + (m + 1));
    bool have_ans = false;
    for(int i = 1, j = 1; i <= n && j <= m; ){
//        opa(i) op(j)
        if(a[i].sz <= b[j]){
            can_val[j].pb(a[i].val);
            i++;
            have_ans = true;
        }
        else j++;
    }
    if(!have_ans){
        cout << "0\n";
        return 0;
    }
    int l = 1, r = m, mid;
    while(l < r){
        mid = (l + r) >> 1;
        if(check(n, m, mid)){
            r = mid;
        }
        else{
            l = mid + 1;
        }
    }
    cout << m - l + 1 << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 2 ms 2648 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2652 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2904 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2652 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 1 ms 2652 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 1 ms 2652 KB Output is correct
23 Correct 1 ms 2652 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 2 ms 2652 KB Output is correct
26 Correct 2 ms 2648 KB Output is correct
27 Correct 1 ms 2652 KB Output is correct
28 Correct 1 ms 2652 KB Output is correct
29 Correct 2 ms 2652 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 2 ms 2652 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2652 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2904 KB Output is correct
38 Correct 90 ms 7420 KB Output is correct
39 Correct 82 ms 4816 KB Output is correct
40 Correct 164 ms 4688 KB Output is correct
41 Correct 117 ms 5836 KB Output is correct
42 Correct 41 ms 3988 KB Output is correct
43 Correct 37 ms 4076 KB Output is correct
44 Correct 146 ms 7724 KB Output is correct
45 Correct 204 ms 5904 KB Output is correct
46 Correct 160 ms 5088 KB Output is correct
47 Correct 178 ms 5640 KB Output is correct
48 Correct 151 ms 4876 KB Output is correct
49 Correct 142 ms 5504 KB Output is correct
50 Correct 115 ms 4716 KB Output is correct
51 Correct 34 ms 3932 KB Output is correct
52 Correct 35 ms 3932 KB Output is correct
53 Correct 36 ms 3924 KB Output is correct
54 Correct 199 ms 5268 KB Output is correct
55 Correct 68 ms 5884 KB Output is correct
56 Correct 22 ms 3928 KB Output is correct
57 Correct 15 ms 3160 KB Output is correct
58 Correct 29 ms 4992 KB Output is correct
59 Correct 40 ms 4972 KB Output is correct
60 Correct 16 ms 3160 KB Output is correct
61 Correct 85 ms 4652 KB Output is correct
62 Correct 199 ms 5988 KB Output is correct
63 Correct 208 ms 5996 KB Output is correct
64 Correct 192 ms 6156 KB Output is correct
65 Correct 204 ms 5972 KB Output is correct
66 Correct 189 ms 6000 KB Output is correct
67 Correct 217 ms 6272 KB Output is correct
68 Correct 200 ms 5968 KB Output is correct
69 Correct 188 ms 5712 KB Output is correct
70 Correct 205 ms 6216 KB Output is correct
71 Correct 177 ms 4964 KB Output is correct
72 Correct 173 ms 5296 KB Output is correct
73 Correct 187 ms 4808 KB Output is correct