Submission #125826

# Submission time Handle Problem Language Result Execution time Memory
125826 2019-07-06T12:16:08 Z EntityIT Exhibition (JOI19_ho_t2) C++14
100 / 100
303 ms 5464 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 252 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 252 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 380 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 252 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 380 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 376 KB Output is correct
31 Correct 3 ms 376 KB Output is correct
32 Correct 2 ms 380 KB Output is correct
33 Correct 2 ms 376 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 376 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 4 ms 376 KB Output is correct
38 Correct 145 ms 4752 KB Output is correct
39 Correct 135 ms 4888 KB Output is correct
40 Correct 194 ms 4984 KB Output is correct
41 Correct 172 ms 4820 KB Output is correct
42 Correct 71 ms 4344 KB Output is correct
43 Correct 71 ms 4344 KB Output is correct
44 Correct 214 ms 4964 KB Output is correct
45 Correct 298 ms 4980 KB Output is correct
46 Correct 240 ms 4980 KB Output is correct
47 Correct 260 ms 4692 KB Output is correct
48 Correct 227 ms 4596 KB Output is correct
49 Correct 211 ms 4056 KB Output is correct
50 Correct 178 ms 4084 KB Output is correct
51 Correct 71 ms 4344 KB Output is correct
52 Correct 71 ms 4344 KB Output is correct
53 Correct 75 ms 4344 KB Output is correct
54 Correct 200 ms 5464 KB Output is correct
55 Correct 114 ms 4856 KB Output is correct
56 Correct 47 ms 3448 KB Output is correct
57 Correct 28 ms 1656 KB Output is correct
58 Correct 53 ms 4060 KB Output is correct
59 Correct 74 ms 3932 KB Output is correct
60 Correct 28 ms 1656 KB Output is correct
61 Correct 109 ms 2980 KB Output is correct
62 Correct 274 ms 4908 KB Output is correct
63 Correct 275 ms 5004 KB Output is correct
64 Correct 303 ms 4992 KB Output is correct
65 Correct 287 ms 4920 KB Output is correct
66 Correct 275 ms 5036 KB Output is correct
67 Correct 290 ms 4904 KB Output is correct
68 Correct 274 ms 4876 KB Output is correct
69 Correct 284 ms 4860 KB Output is correct
70 Correct 276 ms 4920 KB Output is correct
71 Correct 259 ms 4844 KB Output is correct
72 Correct 242 ms 4856 KB Output is correct
73 Correct 237 ms 4892 KB Output is correct