제출 #1333164

#제출 시각아이디문제언어결과실행 시간메모리
1333164lywoemExhibition (JOI19_ho_t2)C++20
100 / 100
38 ms4164 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define l(a, b, i) for (ll i = a; i < b; i++)
#define rl(a, b, i) for (ll i = a; i >= b; i--)
#define vpair vector<pair<ll, ll>>
#define inf LLONG_MAX
#define ninf LLONG_MIN

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll N, M; cin >> N >> M; vector<ll> sz(N + 1, 0), val(N + 1, 0), frame(M + 1, 0);
    vector<pair<ll, ll>> pic(N + 1, {0, 0});
    l(1, N + 1, i) {
        cin >> sz[i] >> val[i]; 
        pic[i] = {val[i], sz[i]};
    }
    l(1, M + 1, i) cin >> frame[i];
    sort(frame.rbegin(), frame.rend() - 1); // sort theo decreasing frame size
    sort(pic.rbegin(), pic.rend() - 1); // sort theo decreasing val ^^

    ll ptr = 1; // keep track xem mình đang ở cái frame nào rùi
    ll cnt = 0;

    l(1, N + 1, i) { // iterate qua pics nhee
        if (ptr > M) break; // vượt max frame mình có rùi :>

        if (pic[i].second <= frame[ptr]) {
            ptr++;
            cnt++;
        }
    }

    cout << cnt;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...