답안 #703587

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703587 2023-02-27T18:14:07 Z niter Self Study (JOI22_ho_t2) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
using ll = long long;
long long A[300050], B[300050];

int main(){
    ll N, M;
    cin >> N >> M;
    loop(i,0,n) cin >> A[i];
    loop(i,0,n) cin >> B[i];
    loop(i,0,n) A[i] = max(A[i], B[i]);

    ll ok = 0, ng = 1LL << 60;
    auto check = [&](ll x) -> bool {
        ll day = 0;
        for(ll i = 0; i < N; i++){
            if(x <= A[i] * M) day += (x + A[i] - 1) / A[i];
            else day += M + (x - A[i] * M + B[i] - 1) / B[i];
            if(day > N * M) return 0;
        }
        return 1;
    };
    while(ng - ok > 1){
        const ll mid = (ng + ok) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:11:14: error: 'n' was not declared in this scope
   11 |     loop(i,0,n) cin >> A[i];
      |              ^
Main.cpp:3:35: note: in definition of macro 'loop'
    3 | #define loop(i,a,b) for(int i=a;i<b;i++)
      |                                   ^
Main.cpp:12:14: error: 'n' was not declared in this scope
   12 |     loop(i,0,n) cin >> B[i];
      |              ^
Main.cpp:3:35: note: in definition of macro 'loop'
    3 | #define loop(i,a,b) for(int i=a;i<b;i++)
      |                                   ^
Main.cpp:13:14: error: 'n' was not declared in this scope
   13 |     loop(i,0,n) A[i] = max(A[i], B[i]);
      |              ^
Main.cpp:3:35: note: in definition of macro 'loop'
    3 | #define loop(i,a,b) for(int i=a;i<b;i++)
      |                                   ^