Submission #914856

# Submission time Handle Problem Language Result Execution time Memory
914856 2024-01-22T18:55:06 Z andrei_iorgulescu Self Study (JOI22_ho_t2) C++14
0 / 100
299 ms 7548 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int n,m,a[300005],b[300005],nev[300005];

int nrparti(int x,int y)
{
    if (x % y == 0)
        return x / y;
    return x / y + 1;
}

bool pot(int x)
{
    int extra = 0;
    for (int i = 1; i <= n; i++)
    {
        nev[i] = x;
        if (a[i] <= b[i])
            extra += m;
        else
        {
            if (x <= m * a[i])
            {
                extra += m - nrparti(x,a[i]);
                nev[i] = 0;
            }
            else
            {
                nev[i] = x - m * a[i];
            }
        }
    }
    for (int i = 1; i <= n; i++)
        if (nev[i] != 0)
            extra -= nrparti(nev[i],b[i]);
    if (extra >= 0)
        return true;
    return false;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
        cin >> b[i];
    int st = 0,pas = 1ll << 60;
    while (pas != 0)
    {
        if (pot(st + pas) == true)
            st += pas;
        pas /= 2;
    }
    cout << st;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4556 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 240 ms 7252 KB Output is correct
12 Correct 237 ms 7480 KB Output is correct
13 Correct 150 ms 7548 KB Output is correct
14 Incorrect 299 ms 7252 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 80 ms 6616 KB Output is correct
10 Correct 53 ms 6772 KB Output is correct
11 Correct 41 ms 6748 KB Output is correct
12 Correct 33 ms 6792 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Incorrect 6 ms 4444 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4556 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 240 ms 7252 KB Output is correct
12 Correct 237 ms 7480 KB Output is correct
13 Correct 150 ms 7548 KB Output is correct
14 Incorrect 299 ms 7252 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4440 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 80 ms 6616 KB Output is correct
10 Correct 53 ms 6772 KB Output is correct
11 Correct 41 ms 6748 KB Output is correct
12 Correct 33 ms 6792 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Incorrect 6 ms 4444 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4440 KB Output is correct
4 Correct 1 ms 4556 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 4 ms 4444 KB Output is correct
11 Correct 240 ms 7252 KB Output is correct
12 Correct 237 ms 7480 KB Output is correct
13 Correct 150 ms 7548 KB Output is correct
14 Incorrect 299 ms 7252 KB Output isn't correct
15 Halted 0 ms 0 KB -