답안 #125860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125860 2019-07-06T13:15:22 Z tselmegkh Exhibition (JOI19_ho_t2) C++14
100 / 100
292 ms 5100 KB
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define MAX 100005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
#define pc __builtin_popcount
#define debug(args...)  cerr << #args << " = "; Dbg,args; cerr << nl;
struct Dbg { template<typename T> Dbg& operator,(const T& v) { cerr << v << ", "; return *this; } } Dbg;
template <typename T> ostream& operator<<(ostream& _o_, const vector<T>& _v_){
if(!_v_.empty()){_o_<<'[';copy(_v_.begin(),_v_.end(),ostream_iterator<T>(_o_,", "));_o_<<"\b\b]";}return _o_;}
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef priority_queue<int, vector<int>, greater<int>> minheap;
template<class C> void mini(C &_a, C _b) { _a = min(_a, _b); }
template<class C> void maxi(C &_a, C _b) { _a = max(_a, _b); }

vii a;
vi b;
int n, m;

bool check(int x){
    minheap q;
    int j = 0, left = -1;
    bool ok = 1;
    for(int i = m - x; i < m; i++){
       while(j < n && a[j].first <= b[i]){
            if(a[j].second >= left)q.push(a[j].second);
            j++;
       }
       if(q.empty())return 0;
       left = q.top();
       q.pop();
    }
    return 1;
}
vi scn(int n){
    vi a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    return a;
}
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        int c, v;
        cin >> c >> v;
        a.emplace_back(c, v);
    }
    b = scn(m);
    sort(all(a)); sort(all(b));

    int l = 0, r = min(n, m);

    while(l != r){
        int mid = (l + r + 1) >> 1;
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid - 1;
        }
    }
    cout << l;

	return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'bool check(int)':
joi2019_ho_t2.cpp:34:10: warning: unused variable 'ok' [-Wunused-variable]
     bool ok = 1;
          ^~
# 결과 실행 시간 메모리 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 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 380 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 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 380 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 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 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 4 ms 508 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 4 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 376 KB Output is correct
33 Correct 3 ms 380 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 380 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 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 380 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 376 KB Output is correct
18 Correct 2 ms 380 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 2 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 4 ms 508 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 4 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 376 KB Output is correct
33 Correct 3 ms 380 KB Output is correct
34 Correct 3 ms 376 KB Output is correct
35 Correct 2 ms 380 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 138 ms 4588 KB Output is correct
39 Correct 126 ms 4592 KB Output is correct
40 Correct 186 ms 4564 KB Output is correct
41 Correct 167 ms 4592 KB Output is correct
42 Correct 64 ms 4076 KB Output is correct
43 Correct 62 ms 4208 KB Output is correct
44 Correct 136 ms 4784 KB Output is correct
45 Correct 292 ms 5064 KB Output is correct
46 Correct 237 ms 4976 KB Output is correct
47 Correct 230 ms 4844 KB Output is correct
48 Correct 210 ms 4976 KB Output is correct
49 Correct 204 ms 4208 KB Output is correct
50 Correct 170 ms 4208 KB Output is correct
51 Correct 64 ms 4080 KB Output is correct
52 Correct 62 ms 4076 KB Output is correct
53 Correct 63 ms 4080 KB Output is correct
54 Correct 196 ms 5100 KB Output is correct
55 Correct 113 ms 4592 KB Output is correct
56 Correct 42 ms 3496 KB Output is correct
57 Correct 24 ms 1800 KB Output is correct
58 Correct 49 ms 4044 KB Output is correct
59 Correct 67 ms 3948 KB Output is correct
60 Correct 25 ms 1784 KB Output is correct
61 Correct 94 ms 2932 KB Output is correct
62 Correct 207 ms 4592 KB Output is correct
63 Correct 207 ms 4616 KB Output is correct
64 Correct 219 ms 4592 KB Output is correct
65 Correct 215 ms 4496 KB Output is correct
66 Correct 207 ms 4572 KB Output is correct
67 Correct 219 ms 4616 KB Output is correct
68 Correct 207 ms 4664 KB Output is correct
69 Correct 214 ms 4624 KB Output is correct
70 Correct 211 ms 4564 KB Output is correct
71 Correct 199 ms 4720 KB Output is correct
72 Correct 175 ms 4528 KB Output is correct
73 Correct 182 ms 4588 KB Output is correct