답안 #912597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912597 2024-01-19T16:17:24 Z ByeWorld Exhibition (JOI19_ho_t2) C++14
100 / 100
60 ms 6768 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#define bupol __builtin_popcount
#define int long long 
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
using namespace std;
const int MAXN = 2e5+5;
const int MAXK = 205;
const int LOG = 20;
const int MOD = 1e9+7;
const int SQRT = 520;
const int INF = 1e18+10;
const int INF2 = 1e18;
typedef pair<ll,ll> pii;
typedef pair<ll,pii> ipii;
bool cmp(pii a, pii b){
    if(a.fi==b.fi) return a.se > b.se;
    return a.fi > b.fi;
}
int n, m;
vector <int> x;
vector <pii> val;

bool cek(int p){
    int idx = 1, i=1, cnt = 0;
    for(i=1; i<=p; i++){
        while(idx<=n && val[idx].se > x[i]){
            idx++;
            continue; // lebih gede
        }
        //if(p==2) cout << idx << " idx\n";
        if(idx<=n && val[idx].se <= x[i]){
            cnt++; idx++;
        }
    }
    if(cnt == p) return 1;
    return 0;
}

void bin(){
    int l=1, r=min(n, m), ans = 0;
    while(l<=r){
        int mid = ((l+r)>>1);
        if(cek(mid)){
            ans = mid;
            l = mid+1;
        } else {
            r = mid-1;
        }
    }
    cout << ans << '\n';
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        int a, b; cin >> a >> b;
        val.pb({b, a});
    }
    val.pb({INF, INF});
    sort(val.begin(), val.end(), cmp);
    for(int i=1; i<=m; i++){
        int pp; cin >> pp; x.pb(pp);
    }
    sort(x.begin(), x.end()); x.pb(-1);
    reverse(x.begin(), x.end());

    // for(auto in : val) cout << in.fi << ' '<< in.se << " in\n";
    // for(auto in : x) cout << in << " pp\n";
    bin();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 1 ms 352 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 372 KB Output is correct
32 Correct 1 ms 496 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 352 KB Output is correct
17 Correct 1 ms 356 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 352 KB Output is correct
22 Correct 1 ms 352 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 372 KB Output is correct
32 Correct 1 ms 496 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 40 ms 3788 KB Output is correct
39 Correct 49 ms 3780 KB Output is correct
40 Correct 49 ms 3744 KB Output is correct
41 Correct 41 ms 3796 KB Output is correct
42 Correct 41 ms 3788 KB Output is correct
43 Correct 42 ms 6648 KB Output is correct
44 Correct 41 ms 6680 KB Output is correct
45 Correct 42 ms 6500 KB Output is correct
46 Correct 40 ms 6532 KB Output is correct
47 Correct 43 ms 6104 KB Output is correct
48 Correct 39 ms 6084 KB Output is correct
49 Correct 36 ms 5576 KB Output is correct
50 Correct 33 ms 5572 KB Output is correct
51 Correct 40 ms 6664 KB Output is correct
52 Correct 44 ms 6600 KB Output is correct
53 Correct 41 ms 6612 KB Output is correct
54 Correct 37 ms 6636 KB Output is correct
55 Correct 43 ms 6596 KB Output is correct
56 Correct 25 ms 4048 KB Output is correct
57 Correct 15 ms 2676 KB Output is correct
58 Correct 25 ms 3916 KB Output is correct
59 Correct 26 ms 4052 KB Output is correct
60 Correct 17 ms 2272 KB Output is correct
61 Correct 26 ms 3972 KB Output is correct
62 Correct 48 ms 6636 KB Output is correct
63 Correct 60 ms 6608 KB Output is correct
64 Correct 49 ms 6612 KB Output is correct
65 Correct 48 ms 6516 KB Output is correct
66 Correct 55 ms 6684 KB Output is correct
67 Correct 47 ms 6684 KB Output is correct
68 Correct 58 ms 6684 KB Output is correct
69 Correct 47 ms 6604 KB Output is correct
70 Correct 44 ms 6668 KB Output is correct
71 Correct 53 ms 6604 KB Output is correct
72 Correct 44 ms 6720 KB Output is correct
73 Correct 54 ms 6768 KB Output is correct