답안 #1094563

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1094563 2024-09-29T23:32:04 Z Izzy Self Study (JOI22_ho_t2) C++14
0 / 100
0 ms 348 KB
#include <vector>
#include <iostream>
using namespace std;

long long n, m;
vector<int> course;
vector<int> study;

bool works(long long target) {
    vector<long long> vals(n); // value of each class rn
    long long hours = n * m;
    long long temp;
    long long left = 0;
    for (int i = 0; i < n; i++) {
        if (course[i] > study[i]) {
            temp = target / course[i];
            if (target % course[i] != 0) {
                temp++;
            }
            temp = min(temp, m);
            hours -= temp;
            vals[i] += course[i] * temp;
        }
        if (vals[i] < target) {
            left = target - vals[i];
            temp = left / study[i];
            if (left % study[i] != 0) {
                temp++;
            }
            hours -= temp;
            vals[i] += temp * study[i];
        }
        if (hours < 0) {
            return false;
        }
        cout << hours << ' ';
    }
    return true;
}

int main() {
    cin >> n >> m;
    course.resize(n);
    study.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> course[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> study[i];
    }
    // binary search for max min comprehension lvl
    long long low = 0;
    long long high = 1e18;
    long long mid;
    long long working = 0;
    while (low <= high) {
        mid = (low + high) / 2;
        if (works(mid)) {
            working = mid;
            low = mid + 1;
        }
        else {
            high = mid - 1;
        }
    }
    cout << working;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -