Submission #1232946

#TimeUsernameProblemLanguageResultExecution timeMemory
1232946CrabCNHExhibition (JOI19_ho_t2)C++20
100 / 100
35 ms4420 KiB
#include <bits/stdc++.h>

#define task     "BriantheCrab"

#define int    long long
#define pii    pair <int, int>
#define fi     first
#define se     second
#define szf    sizeof
#define sz(s)  (int)((s).size())
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

template <class T> void minimize (T &t, T f) {if (t > f) t = f;}
template <class T> void maximize (T &t, T f) {if (t < f) t = f;}

const int maxN = 2e5 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;

// khong tu code thi khong kha len duoc dau

int n, m;
int s[maxN], v[maxN], c[maxN];

void solve () {
    priority_queue <pii> pq;
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) {
        cin >> s[i] >> v[i];
        pq.push ({v[i], s[i]});
    }
    for (int i = 1; i <= m; i ++) {
        cin >> c[i];
    } 
    sort (c + 1, c + m + 1, greater <int> ());
    int res = 0;
    for (int i = 1; i <= m; i ++) {
        while (sz (pq) && pq.top ().se > c[i]) {
            pq.pop ();
        }
        if (sz (pq)) {
            res ++;
            pq.pop ();
        }
        else {
            break;
        }
    }
    cout << res;
    return;
}

signed main () {
    cin.tie (nullptr) -> sync_with_stdio (false);
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int t = 1;
    //cin >> t;
    while (t --) {
        solve ();
    } 
    return 0;
}
// thfv

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:62:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:63:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...