답안 #970590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970590 2024-04-26T18:01:21 Z hariaakas646 Exhibition (JOI19_ho_t2) C++14
100 / 100
370 ms 9132 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;


void usaco()
{
    freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int n, m;
vii vec;
vi sz;

bool check(int x) {
    mseti st;
    int id = 0;
    int ma = 0;
    for(int i=x-1; i>=0; i--) {
        int v = sz[i];
        while(id < n && vec[id].f <= v) {
            if(vec[id].s >= ma)
                st.insert(vec[id].s);
            id++;
        }
        if(!st.size()) return false;
        // printf("%d %d\n", i, *st.begin());
        ma = max(ma, *st.begin());
        st.erase(st.begin());
    }
    return true;

}

int main() {
    // usaco();
    scd(n);
    scd(m);
    vec = vii(n);
    sz = vi(m);

    frange(i, n) {
        scd(vec[i].f);
        scd(vec[i].s);
    }

    frange(i, m) {
        scd(sz[i]);
    }

    sort(all(vec));
    sort(all(sz), greater<>());

    int lo = 0;
    int hi = m;

    while(lo != hi) {
        int mid = (lo+hi+1)/2;
        // printf("%d %d\n", lo, hi);
        if(check(mid)) {
            lo = mid;
        }
        else {
            hi = mid-1;
        }
    }
    printf("%d\n", lo);
}

Compilation message

joi2019_ho_t2.cpp: In function 'void usaco()':
joi2019_ho_t2.cpp:30:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     freopen("/media/hariaakash646/785EF1075EF0BF46/CompetitiveProgramming/input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:60:5: note: in expansion of macro 'scd'
   60 |     scd(n);
      |     ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:61:5: note: in expansion of macro 'scd'
   61 |     scd(m);
      |     ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:66:9: note: in expansion of macro 'scd'
   66 |         scd(vec[i].f);
      |         ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:67:9: note: in expansion of macro 'scd'
   67 |         scd(vec[i].s);
      |         ^~~
joi2019_ho_t2.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
joi2019_ho_t2.cpp:71:9: note: in expansion of macro 'scd'
   71 |         scd(sz[i]);
      |         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 432 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 432 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 448 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 432 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 448 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 504 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 146 ms 6844 KB Output is correct
39 Correct 145 ms 6740 KB Output is correct
40 Correct 175 ms 7344 KB Output is correct
41 Correct 149 ms 6972 KB Output is correct
42 Correct 38 ms 4436 KB Output is correct
43 Correct 37 ms 4436 KB Output is correct
44 Correct 138 ms 6828 KB Output is correct
45 Correct 370 ms 8532 KB Output is correct
46 Correct 315 ms 8316 KB Output is correct
47 Correct 316 ms 7572 KB Output is correct
48 Correct 280 ms 7508 KB Output is correct
49 Correct 237 ms 6444 KB Output is correct
50 Correct 244 ms 6228 KB Output is correct
51 Correct 37 ms 4412 KB Output is correct
52 Correct 39 ms 4504 KB Output is correct
53 Correct 40 ms 4448 KB Output is correct
54 Correct 240 ms 9132 KB Output is correct
55 Correct 191 ms 6872 KB Output is correct
56 Correct 33 ms 5468 KB Output is correct
57 Correct 15 ms 1808 KB Output is correct
58 Correct 83 ms 7624 KB Output is correct
59 Correct 213 ms 7812 KB Output is correct
60 Correct 15 ms 1628 KB Output is correct
61 Correct 98 ms 3940 KB Output is correct
62 Correct 223 ms 6848 KB Output is correct
63 Correct 232 ms 6860 KB Output is correct
64 Correct 238 ms 6660 KB Output is correct
65 Correct 237 ms 6992 KB Output is correct
66 Correct 227 ms 6856 KB Output is correct
67 Correct 235 ms 6848 KB Output is correct
68 Correct 234 ms 6856 KB Output is correct
69 Correct 255 ms 6828 KB Output is correct
70 Correct 229 ms 6864 KB Output is correct
71 Correct 218 ms 6860 KB Output is correct
72 Correct 214 ms 6796 KB Output is correct
73 Correct 209 ms 6832 KB Output is correct