답안 #1099167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1099167 2024-10-10T16:26:16 Z serifefedartar Exhibition (JOI19_ho_t2) C++17
100 / 100
53 ms 6468 KB
#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 100;

int n, m;
vector<pair<int,int>> v1;
vector<int> v2;

bool check(int x) {
    vector<pair<int,int>> vv(v1.begin(), v1.end());
    reverse(vv.begin(), vv.end());
    vector<int> Q;
    for (int i = m - x; i < m; i++)
        Q.push_back(v2[i]);

    for (auto u : Q) {
        while (vv.size() && vv.back().f > u)
            vv.pop_back();
        if (vv.empty())
            return false;
        vv.pop_back();
    }
    return true;
}

int main() {
    fast;
    cin >> n >> m;

    v1 = vector<pair<int,int>>(n);
    v2 = vector<int>(m);
    for (int i = 0; i < n; i++)
        cin >> v1[i].f >> v1[i].s;
    for (int i = 0; i < m; i++)
        cin >> v2[i];

    sort(v1.begin(), v1.end(), [&](pair<int,int> A, pair<int,int> B) {
        return make_pair(A.s, A.f) < make_pair(B.s, B.f);
    });
    sort(v2.begin(), v2.end());

    int L = 1, R = min(n, m);
    int ans = 0;
    while (R >= L) {
        int mid = L + (R - L) / 2;
        if (check(mid)) {
            ans = mid;
            L = mid + 1;
        } else
            R = mid - 1;
    }
    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 388 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 388 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 424 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 500 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 496 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 388 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 460 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 604 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 424 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 500 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 496 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 51 ms 6216 KB Output is correct
39 Correct 47 ms 6232 KB Output is correct
40 Correct 41 ms 6268 KB Output is correct
41 Correct 47 ms 6196 KB Output is correct
42 Correct 47 ms 5588 KB Output is correct
43 Correct 41 ms 5588 KB Output is correct
44 Correct 39 ms 6032 KB Output is correct
45 Correct 49 ms 6228 KB Output is correct
46 Correct 46 ms 6176 KB Output is correct
47 Correct 53 ms 5696 KB Output is correct
48 Correct 43 ms 5712 KB Output is correct
49 Correct 52 ms 5048 KB Output is correct
50 Correct 38 ms 5020 KB Output is correct
51 Correct 40 ms 5572 KB Output is correct
52 Correct 42 ms 5552 KB Output is correct
53 Correct 40 ms 5460 KB Output is correct
54 Correct 43 ms 6468 KB Output is correct
55 Correct 48 ms 6212 KB Output is correct
56 Correct 23 ms 3932 KB Output is correct
57 Correct 14 ms 1628 KB Output is correct
58 Correct 23 ms 3920 KB Output is correct
59 Correct 28 ms 3928 KB Output is correct
60 Correct 15 ms 1628 KB Output is correct
61 Correct 25 ms 3208 KB Output is correct
62 Correct 48 ms 6068 KB Output is correct
63 Correct 46 ms 6068 KB Output is correct
64 Correct 47 ms 6072 KB Output is correct
65 Correct 46 ms 6056 KB Output is correct
66 Correct 45 ms 6068 KB Output is correct
67 Correct 50 ms 6068 KB Output is correct
68 Correct 46 ms 6076 KB Output is correct
69 Correct 46 ms 6068 KB Output is correct
70 Correct 45 ms 6036 KB Output is correct
71 Correct 44 ms 6068 KB Output is correct
72 Correct 41 ms 6068 KB Output is correct
73 Correct 43 ms 6060 KB Output is correct