제출 #125826

#제출 시각아이디문제언어결과실행 시간메모리
125826EntityITExhibition (JOI19_ho_t2)C++14
100 / 100
303 ms5464 KiB
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second

const int N = (int)1e5 + 5, M = N;
int n, m, c[M];
pair<int, int> picture[N];

bool check (int mid) {
    priority_queue<int, vector<int>, greater<int> > pq;
    int iPicture = 1, cur = 0;
    for (int i = m - mid + 1; i <= m; ++i) {
        while (iPicture <= n && picture[iPicture].fi <= c[i]) {
            pq.push(picture[iPicture].se);
            ++iPicture;
        }
        while (!pq.empty() && pq.top() < cur) pq.pop();
        if (pq.empty() ) return false ;
        cur = pq.top(); pq.pop();
    }
    return true ;
}

int main () {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d %d", &picture[i].fi, &picture[i].se);
    for (int i = 1; i <= m; ++i) scanf("%d", c + i);
    sort(picture + 1, picture + n + 1);
    sort(c + 1, c + m + 1);

    int lAns = 0, rAns = min(n, m);
    while (lAns < rAns) {
        int mid = (lAns + rAns + 1) >> 1;
        if (check(mid) ) lAns = mid;
        else rAns = mid - 1;
    }

    cout << lAns;

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:29:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; ++i) scanf("%d %d", &picture[i].fi, &picture[i].se);
                                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp:30:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= m; ++i) scanf("%d", c + i);
                                  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...