답안 #999548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
999548 2024-06-15T18:36:30 Z gmroh06 Matryoshka (JOI16_matryoshka) C++14
100 / 100
114 ms 18776 KB
#import <bits/stdc++.h>

using namespace std;
using ll = long long;

inline void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
}

int main() {
    init();

    ll n, q;

    cin >> n >> q;

    vector<pair<ll, ll>> v(n);
    vector<tuple<ll, ll, ll>> query(q);

    for (auto& [a, b] : v) {
        cin >> a >> b;
        b *= -1;
    }

    sort(v.rbegin(), v.rend());

    for (ll i = 0, a, b; i < q; i++) {
        cin >> a >> b;
        query[i] = tie(a, b, i);
    }

    sort(query.rbegin(), query.rend());

    vector<ll> ans(q);
    vector<ll> dp;
    auto it = v.begin();

    for (auto& [a, b, idx] : query) {
        for (; it < v.end() and a <= it -> first; it++) {
            auto s = upper_bound(dp.begin(), dp.end(), -it -> second);

            if (s == dp.end()) {
                dp.emplace_back(-it -> second);
            } else {
                *s = -it -> second;
            }
        }

        ans[idx] = upper_bound(dp.begin(), dp.end(), b) - dp.begin();
    }

    for (auto& x : ans) {
        cout << x << '\n';
    }

    return 0;
}

Compilation message

matryoshka.cpp:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    1 | #import <bits/stdc++.h>
      |  ^~~~~~
matryoshka.cpp: In function 'int main()':
matryoshka.cpp:22:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   22 |     for (auto& [a, b] : v) {
      |                ^
matryoshka.cpp:40:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |     for (auto& [a, b, idx] : query) {
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 348 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 348 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 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 0 ms 348 KB Output is correct
15 Correct 0 ms 424 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 348 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 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 0 ms 348 KB Output is correct
15 Correct 0 ms 424 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 1 ms 616 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 344 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 348 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 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 0 ms 348 KB Output is correct
15 Correct 0 ms 424 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 1 ms 604 KB Output is correct
26 Correct 1 ms 604 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 2 ms 468 KB Output is correct
33 Correct 1 ms 616 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 2 ms 856 KB Output is correct
36 Correct 101 ms 15572 KB Output is correct
37 Correct 95 ms 14924 KB Output is correct
38 Correct 34 ms 5720 KB Output is correct
39 Correct 79 ms 13396 KB Output is correct
40 Correct 89 ms 14292 KB Output is correct
41 Correct 98 ms 14780 KB Output is correct
42 Correct 78 ms 13012 KB Output is correct
43 Correct 50 ms 14392 KB Output is correct
44 Correct 112 ms 18272 KB Output is correct
45 Correct 107 ms 18252 KB Output is correct
46 Correct 114 ms 18124 KB Output is correct
47 Correct 97 ms 18160 KB Output is correct
48 Correct 105 ms 18776 KB Output is correct
49 Correct 100 ms 18004 KB Output is correct
50 Correct 106 ms 18512 KB Output is correct