제출 #1267750

#제출 시각아이디문제언어결과실행 시간메모리
1267750gustavo_dSelf Study (JOI22_ho_t2)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAXN = 3e5;
const ll INF = 1e18;

ll a[MAXN], b[MAXN];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n, days; cin >> n >> days;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];

    if (days == 1) {
        int B = 0;
        for (int i=0; i<n; i++) B += b[i] >= a[i];
        if (B >= 2) {
            ll ans = INF;
            for (int i=0; i<n; i++) {
                ans = min(ans, max(a[i], b[i]));
            }
            cout << ans << '\n';
        } else {
            ll ans = INF, mxB = 0; int check = -1;
            for (int i=0; i<n; i++) {
                if (b[i] > a[i]) {
                    check = i;
                    continue;
                }
                ans = min(ans, a[i]);
                mxB = max(mxB, b[i]);
            }
            if (check == -1 or a[check] >= ans) cout << ans << '\n';
            else cout << max(a[check], min({b[check], ans, mxB})) << '\n';
        }
    } else {
        // ll l = 0, r = 1000000000LL * days; ll ans = 0;
        // while (l <= r) {
        //     ll mid = (l + r) / 2;
            
        //     ll available = 0, needed = 0;
        //     for (int i=0; i<n; i++) {
        //         if (days * a[i] mid)
        //     }

        //     if (available >= needed) {
        //         ans = mid;
        //         l = mid+1;
        //     } else r = mid-1;
        // }
        // cout << ans << '\n';
    }

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...