Submission #1050913

#TimeUsernameProblemLanguageResultExecution timeMemory
1050913manhlinh1501Exhibition (JOI19_ho_t2)C++17
100 / 100
34 ms1632 KiB
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
const int MAXN = 1e5 + 5;
#define ALL(a) (a).begin(), (a).end()
#define LB(a, x) (lower_bound(ALL(a), x) - (a).begin() + 1)
int N, M;
pii a[MAXN];
int b[MAXN];
signed main() {
#define TASK "code"

    if (fopen(TASK ".inp", "r")) {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) cin >> a[i].first >> a[i].second;
    for(int i = 1; i <= M; i++) cin >> b[i];
    sort(a + 1, a + N + 1, [&](const pii a, const pii b) {
        if(a.second != b.second) return a.second < b.second;
        return a.first < b.first;
    });
    sort(b + 1, b + M + 1);
    int j = N;
    int ans = 0;
    for(int i = M; i >= 1; i--) {
        while(j >= 1 and a[j].first > b[i])
            j--;
        if(j > 0 and a[j].first <= b[i]) {
            j--;
            ans++;
        }
    }
    cout << ans;
    return (0 ^ 0);
}

Compilation message (stderr)

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