Submission #878737

# Submission time Handle Problem Language Result Execution time Memory
878737 2023-11-25T06:51:43 Z frostray8653 Exhibition (JOI19_ho_t2) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }

const int N = 100005;
pii a[N];
int c[N];

signed main() {
    IO;

    int n, m;
    cin >> n >> m;
    FOR(i, 0, n - 1) cin >> a[i].first >> a[i].second;
    FOR(i, 0, m - 1) cin >> c[i];
    sort(a, a + n, [&](pii p, pii q) {
        if (p.first != q.first)
            return p.first > q.first;
        return p.second > q.second;
    });
    sort(c, c + m, greater<int>());
    vector<int> tmp;
    FOR(i, 0, n - 1) {
        int l = -1, r = tmp.size();
        while (l + 1 < r) {
            int mid = (l + r) >> 1;
            if (a[i].second > tmp[mid])
                r = mid;
            else
                l = mid;
        }
        if (r == (int)tmp.size()) {
            if (r < m && a[i].first <= c[r])
                tmp.push_back(a[i].second);
        } else {
            if (r < m && a[i].first <= c[r])
                tmp[r] = a[i].second;
        }
    }
    cout << tmp.size() << "\n";
    // for (int i : tmp) dbg(i);

    return 0;
}
/*
4 3
100 1
9 1
8 1
7 1
100 10 5
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 0 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 0 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Incorrect 0 ms 2396 KB Output isn't correct
6 Halted 0 ms 0 KB -