제출 #824977

#제출 시각아이디문제언어결과실행 시간메모리
824977phoenixSelf Study (JOI22_ho_t2)C++17
100 / 100
238 ms11564 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 3e5 + 10;
ll n, m;
ll A[N], B[N];

ll divi(ll a, ll b) {
    return (a + b - 1) / b;
}

bool check(ll x) {
    unsigned long long s = 0;
    for(int i = 0; i < n; i++) {
        if(B[i] >= A[i]) {
            s += divi(x, B[i]);
        } else {
            ll t = min(m, divi(x, A[i]));
            s += t + divi(max(x - t * A[i], 0ll), B[i]);
        }
        if(s > n * m) return 0;
    }
    return 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i < n; i++) 
        cin >> A[i];
    for(int i = 0; i < n; i++) 
        cin >> B[i];
    ll l = 0, r = 2e18;
    while(r - l > 1) {
        ll mid = (l + r) / 2;
        if(check(mid)) l = mid;
        else r = mid;
    }
    cout << l;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool check(ll)':
Main.cpp:23:14: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'll' {aka 'long long int'} [-Wsign-compare]
   23 |         if(s > n * m) 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...