답안 #783902

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
783902 2023-07-15T12:05:56 Z borisAngelov Self Study (JOI22_ho_t2) C++17
0 / 100
426 ms 5124 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 300005;

int n;
long long m;

long long a[maxn];
long long b[maxn];

long long round_up(long long x, long long y)
{
    if (x % y == 0)
    {
        return x / y;
    }

    return x / y + 1;
}

bool check(long long min_score)
{
    long long free_lections = 0;

    for (int i = 1; i <= n; ++i)
    {
        if (b[i] >= a[i])
        {
            long long curr = round_up(min_score, b[i]);
            free_lections += (m - curr);
        }
        else
        {
            long long curr_lections = round_up(min_score, a[i]);

            if (curr_lections <= m)
            {
                free_lections += (m - curr_lections);
            }
            else
            {
                long long add_lections = round_up(min_score - m * a[i], b[i]);
                free_lections -= add_lections;
            }
        }
    }

    return free_lections >= 0;
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fastIO();

    cin >> n >> m;

    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }

    for (int i = 1; i <= n; ++i)
    {
        cin >> b[i];
    }

    long long l = 0;
    long long r = 1e18;

    while (l <= r)
    {
        long long mid = (l + r) / 2;

        if (check(mid) == false)
        {
            r = mid - 1;
        }
        else
        {
            l = mid + 1;
        }
    }

    cout << r << 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 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 179 ms 5104 KB Output is correct
12 Correct 190 ms 5108 KB Output is correct
13 Correct 132 ms 5124 KB Output is correct
14 Incorrect 426 ms 5124 KB Output isn't correct
15 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 71 ms 2796 KB Output is correct
10 Correct 50 ms 2004 KB Output is correct
11 Correct 36 ms 1620 KB Output is correct
12 Correct 29 ms 1368 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 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 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 179 ms 5104 KB Output is correct
12 Correct 190 ms 5108 KB Output is correct
13 Correct 132 ms 5124 KB Output is correct
14 Incorrect 426 ms 5124 KB Output isn't correct
15 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 71 ms 2796 KB Output is correct
10 Correct 50 ms 2004 KB Output is correct
11 Correct 36 ms 1620 KB Output is correct
12 Correct 29 ms 1368 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 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 1 ms 328 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 179 ms 5104 KB Output is correct
12 Correct 190 ms 5108 KB Output is correct
13 Correct 132 ms 5124 KB Output is correct
14 Incorrect 426 ms 5124 KB Output isn't correct
15 Halted 0 ms 0 KB -