Submission #109456

# Submission time Handle Problem Language Result Execution time Memory
109456 2019-05-06T15:40:24 Z wasyl Exhibition (JOI19_ho_t2) C++11
100 / 100
71 ms 4496 KB
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e5, maxm = 1e5;

int n, m, ilo[maxm];
pair< int, int > tab[nax + 1];

bool spr(const int v)
{
    int pt = m - 1 - v + 1;
    for (int i = 0; i < n and pt < m; ++i)
        if (tab[i].nd <= ilo[pt]) ++pt;
    return pt == m;
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;

    for (int i = 0; i < n; ++i)
        cin >> tab[i].nd >> tab[i].st;

    sort(begin(tab), begin(tab) + n);

    for (int i = 0; i < m; ++i)
        cin >> ilo[i];

    sort(begin(ilo), begin(ilo) + m);

    int lo = 0, hi = min(n, m);

    while (lo < hi) 
    {
        int mi = (lo + hi + 1) / 2;
        if (spr(mi)) lo = mi;
        else hi = mi - 1;
    }

    print(lo);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 432 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 4 ms 432 KB Output is correct
29 Correct 4 ms 384 KB Output is correct
30 Correct 4 ms 460 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 3 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
37 Correct 2 ms 384 KB Output is correct
38 Correct 51 ms 4344 KB Output is correct
39 Correct 55 ms 4340 KB Output is correct
40 Correct 68 ms 4472 KB Output is correct
41 Correct 63 ms 4452 KB Output is correct
42 Correct 60 ms 4472 KB Output is correct
43 Correct 54 ms 4344 KB Output is correct
44 Correct 60 ms 4472 KB Output is correct
45 Correct 66 ms 4344 KB Output is correct
46 Correct 63 ms 4472 KB Output is correct
47 Correct 58 ms 3960 KB Output is correct
48 Correct 36 ms 4088 KB Output is correct
49 Correct 44 ms 3576 KB Output is correct
50 Correct 45 ms 3576 KB Output is correct
51 Correct 51 ms 4344 KB Output is correct
52 Correct 60 ms 4472 KB Output is correct
53 Correct 58 ms 4344 KB Output is correct
54 Correct 50 ms 4344 KB Output is correct
55 Correct 64 ms 4344 KB Output is correct
56 Correct 44 ms 3064 KB Output is correct
57 Correct 23 ms 1792 KB Output is correct
58 Correct 38 ms 3116 KB Output is correct
59 Correct 35 ms 3104 KB Output is correct
60 Correct 21 ms 1664 KB Output is correct
61 Correct 35 ms 2680 KB Output is correct
62 Correct 62 ms 4472 KB Output is correct
63 Correct 61 ms 4472 KB Output is correct
64 Correct 65 ms 4472 KB Output is correct
65 Correct 59 ms 4472 KB Output is correct
66 Correct 59 ms 4472 KB Output is correct
67 Correct 58 ms 4472 KB Output is correct
68 Correct 60 ms 4472 KB Output is correct
69 Correct 71 ms 4448 KB Output is correct
70 Correct 68 ms 4344 KB Output is correct
71 Correct 70 ms 4360 KB Output is correct
72 Correct 65 ms 4344 KB Output is correct
73 Correct 65 ms 4496 KB Output is correct