답안 #1112084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1112084 2024-11-13T16:12:31 Z eueka Exhibition (JOI19_ho_t2) C++14
0 / 100
1 ms 2384 KB
#include <bits/stdc++.h>
#define NAME "BWTREE"
#define ll long long
#define ii pair<ll, ll>
#define mo(i, a, b) for (int i = a; i <= b; i++)
#define me(i, a, b) for (int i = a; i >= b; i--)
#define bit(mask, i) ((mask >> i) & 1)
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
const ll N = 1e6 + 5;
const ll mod = 1e9 + 7;
const ll base = 31;
const ll inf = 1e18;
using namespace std;
ii a[N];
ll c[N], n, m;
ll cmp(ii a, ii b){
    if(a.first == b.first) return a.second < b.second;
    return a.first < b.first;
}
ll check(ll k){
    ll j = m - k;
    mo(i, 1, n){
        if(j == m) break;
        if(a[i].first <= c[j]) j++;
    }
    return j == m;
}
int main()
{
    ///freopen(NAME".inp", "r", stdin);
    ///freopen(NAME".out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    mo(i, 1, n) cin >> a[i].first >> a[i].second;
    mo(i, 1, m) cin >> c[i];
    sort(a + 1, a + n + 1, cmp);
    sort(c + 1, c + m + 1);
    ll l  = 0, r = min(n, m);
    while(r - l > 1){
        ll mid = l + r >> 1;
        if(check(mid)) l = mid;
        else r = mid;
    }
    cout << l << "\n";
    cerr << "Time elapsed: " << TIME << "s.\n";
    return 0;
}

Compilation message

joi2019_ho_t2.cpp: In function 'int main()':
joi2019_ho_t2.cpp:42:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |         ll mid = l + r >> 1;
      |                  ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Halted 0 ms 0 KB -