답안 #612376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
612376 2022-07-29T13:41:55 Z boris_mihov Self Study (JOI22_ho_t2) C++14
0 / 100
305 ms 5004 KB
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

typedef long long llong;
const int MAXN = 300000 + 10;
const llong INF = 1e18;

llong n, m;
llong a[MAXN], b[MAXN];
llong achieved[MAXN];

bool check(llong value)
{
    llong freeB = 0;
    for (int i = 1 ; i <= n ; ++i)
    {
        if (b[i] >= a[i])
        {
            llong currLections = (value / b[i] + ((value % b[i]) > 0));
            freeB += m - currLections;
        } else
        {
            llong currLections = std::min(m, (value / a[i] + ((value % a[i]) > 0)));
            if (value <= m * a[i]) freeB += m - currLections;
            else
            {
                llong moreLections = (value - m * a[i]) / b[i] + (((value - m * a[i]) % b[i]) > 0);
                freeB -= moreLections;
            }
        }
    }

    return freeB >= 0;
}

void solve()
{
    llong l = 0, r = INF + 1, mid;
    while (l < r - 1)
    {
        mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }

    std::cout << l << '\n';
}

void read()
{
    std::cin >> n >> m;
    for (int i = 1 ; i <= n ; ++i) std::cin >> a[i];
    for (int i = 1 ; i <= n ; ++i) std::cin >> b[i];
}

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

int main()
{
    fastIO();
    read();
    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 165 ms 4948 KB Output is correct
12 Correct 169 ms 4900 KB Output is correct
13 Correct 172 ms 5004 KB Output is correct
14 Incorrect 305 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 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 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 84 ms 2672 KB Output is correct
10 Correct 55 ms 1884 KB Output is correct
11 Correct 43 ms 1436 KB Output is correct
12 Correct 33 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 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 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 165 ms 4948 KB Output is correct
12 Correct 169 ms 4900 KB Output is correct
13 Correct 172 ms 5004 KB Output is correct
14 Incorrect 305 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 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 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 84 ms 2672 KB Output is correct
10 Correct 55 ms 1884 KB Output is correct
11 Correct 43 ms 1436 KB Output is correct
12 Correct 33 ms 1236 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 0 ms 340 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 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 165 ms 4948 KB Output is correct
12 Correct 169 ms 4900 KB Output is correct
13 Correct 172 ms 5004 KB Output is correct
14 Incorrect 305 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -