답안 #703610

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

void db(){
    cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
    cout << XXX << " ";  db(YYY...);
}

int main(){
//    ios::sync_with_stdio(false); cin.tie(0);
    long long N, M;
    cin >> N >> M;
    loop(i,0,N) cin >> A[i];
    loop(i,0,N) cin >> B[i];

    long long ok = 0, ng = 1LL << 60;
    auto check = [&](long long x) -> bool {
        long long day = 0, cost, day_test = 0;
        loop(i,0,N){
            if(x <= max(A[i], B[i]) * M) day += (x - 1) / max(A[i], B[i]) + 1;
            else day += M + (x - max(A[i], B[i]) * M - 1) / B[i] + 1;

            cost = x;
            cost -= min<long long>(((cost-1) / max(A[i], B[i]) + 1), M) * max(A[i], B[i]);
            if(x <= max(A[i], B[i]) * M)
                if(min<long long>(((cost-1) / max(A[i], B[i]) + 1), M) != M)
                    exit(0);
            day_test += min<long long>(((cost-1) / max(A[i], B[i]) + 1), M);
            if(cost > 0)
                day_test += ((cost-1) / B[i] + 1);
            //if(day != day_test) exit(0);
            if(day > N * M) return 0;
        }
        return 1;
    };
    while(ng - ok > 1){
        //db();
        long long mid = (ng + ok) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 5 ms 372 KB Output is correct
11 Correct 293 ms 4864 KB Output is correct
12 Correct 285 ms 4940 KB Output is correct
13 Correct 209 ms 5036 KB Output is correct
14 Correct 191 ms 4940 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 79 ms 4876 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 79 ms 4876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 5 ms 372 KB Output is correct
11 Correct 293 ms 4864 KB Output is correct
12 Correct 285 ms 4940 KB Output is correct
13 Correct 209 ms 5036 KB Output is correct
14 Correct 191 ms 4940 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 79 ms 4876 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 79 ms 4876 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 5 ms 372 KB Output is correct
11 Correct 293 ms 4864 KB Output is correct
12 Correct 285 ms 4940 KB Output is correct
13 Correct 209 ms 5036 KB Output is correct
14 Correct 191 ms 4940 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 79 ms 4876 KB Output isn't correct
17 Halted 0 ms 0 KB -