답안 #1014841

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1014841 2024-07-05T15:40:18 Z aufan Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        int n, m;
        cin >> n >> m;

        vector<int> s(n), v(n), b;
        for (int i = 0; i < n; i++) {
                cin >> s[i] >> v[i];

                b.push_back(v[i]);
        }
        sort(b.begin(), b.end());       
        b.erase(unique(b.begin(), b.end()), b.end());

        vector<int> c(m);
        for (int i = 0; i < m; i++) cin >> c[i];
        sort(c.begin(), c.end());

        vector<int> ord(n);
        iota(ord.begin(), ord.end(), 0);
        sort(ord.begin(), ord.end(), [&](int x, int y) {
                if (s[x] == s[y]) return s[x] > s[y];
                return s[x] > s[y];
        });

        int k = (int)b.size();
        vector<int> fen(k + 1);

        auto get = [&](int x) {
                return lower_bound(b.begin(), b.end(), x) - b.begin();
        };

        auto upd = [&](int x, int val) {
                for (; x <= k; x += x & -x) fen[x] = max(fen[x], val);
        };

        auto qry = [&](int x) {
                int res = 0;
                for (; x > 0; x -= x & -x) res = max(res, fen[x]);
                return res;
        };

        int ans = 0;
        for (auto i : ord) {
                int lf = 0, rg = m - 1, pos = m;
                while (lf <= rg) {
                        int md = (lf + rg) / 2;

                        if (s[i] <= c[md]) {
                                pos = md;
                                rg = md - 1;
                        } else {
                                lf = md + 1;
                        }
                }

                int res = min(m - pos - 1, qry(k - get(v[i]))) + 1;
                ans = max(ans, res);
                upd(k - get(v[i]), res);
        }

        cout << ans << '\n';
        
        return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -