Submission #636673

# Submission time Handle Problem Language Result Execution time Memory
636673 2022-08-29T22:20:05 Z danikoynov Self Study (JOI22_ho_t2) C++14
64 / 100
388 ms 11332 KB
/**
 ____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|

**/

#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll maxn = 300010;
ll n, m;
ll a[maxn], b[maxn], in[maxn], out[maxn], cp[maxn];

void solve()
{
    cin >> n >> m;
    bool diff = false;
    for (ll i = 1; i <= n; i ++)
        cin >> a[i];
    for (ll i = 1; i <= n; i ++)
    {
        cin >> b[i];
        if (b[i] != a[i])
            diff = true;
    }

    if (m == 1)
    {
        ll mx = 1e9;
        for (int i = 1; i <= n; i ++)
            mx = min(mx, max(a[i], b[i]));
        cout << mx << endl;
    }
    else
    if (!diff)
    {
        double sum = 0;
        for (int i = 1; i <= n; i ++)
            sum = sum + (double)m / (double)(n) * (double)a[i];

        ll lf = 0, rf = ceil(sum);
        while(lf <= rf)
        {
            ll mf = (lf + rf) / 2;
            ll nec = 0;
            for (int i = 1; i <= n; i ++)
            {
                nec = nec + mf / a[i];
                if (mf % a[i] != 0)
                    nec ++;
            }
            if (nec <= n * m)
                lf = mf + 1;
            else
                rf = mf - 1;
        }
        cout << rf << endl;
    }
}

int main()
{
    solve();
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 205 ms 4864 KB Output is correct
12 Correct 202 ms 4924 KB Output is correct
13 Correct 149 ms 4872 KB Output is correct
14 Correct 150 ms 4960 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 75 ms 4948 KB Output is correct
17 Correct 221 ms 4924 KB Output is correct
18 Correct 207 ms 5040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 75 ms 4948 KB Output is correct
3 Correct 221 ms 4924 KB Output is correct
4 Correct 207 ms 5040 KB Output is correct
5 Correct 1 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 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 124 ms 2608 KB Output is correct
14 Correct 87 ms 1784 KB Output is correct
15 Correct 62 ms 1472 KB Output is correct
16 Correct 51 ms 1204 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 5 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 205 ms 4864 KB Output is correct
12 Correct 202 ms 4924 KB Output is correct
13 Correct 149 ms 4872 KB Output is correct
14 Correct 150 ms 4960 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 124 ms 2608 KB Output is correct
24 Correct 87 ms 1784 KB Output is correct
25 Correct 62 ms 1472 KB Output is correct
26 Correct 51 ms 1204 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 392 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 75 ms 4948 KB Output is correct
36 Correct 221 ms 4924 KB Output is correct
37 Correct 207 ms 5040 KB Output is correct
38 Incorrect 0 ms 212 KB Output isn't correct
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 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 124 ms 2608 KB Output is correct
10 Correct 87 ms 1784 KB Output is correct
11 Correct 62 ms 1472 KB Output is correct
12 Correct 51 ms 1204 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 5 ms 392 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 75 ms 4948 KB Output is correct
22 Correct 221 ms 4924 KB Output is correct
23 Correct 207 ms 5040 KB Output is correct
24 Correct 51 ms 952 KB Output is correct
25 Correct 138 ms 4972 KB Output is correct
26 Correct 41 ms 1392 KB Output is correct
27 Correct 250 ms 10864 KB Output is correct
28 Correct 248 ms 10804 KB Output is correct
29 Correct 257 ms 10688 KB Output is correct
30 Correct 279 ms 10784 KB Output is correct
31 Correct 367 ms 10828 KB Output is correct
32 Correct 157 ms 6076 KB Output is correct
33 Correct 388 ms 11332 KB Output is correct
34 Correct 187 ms 6092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 205 ms 4864 KB Output is correct
12 Correct 202 ms 4924 KB Output is correct
13 Correct 149 ms 4872 KB Output is correct
14 Correct 150 ms 4960 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 124 ms 2608 KB Output is correct
24 Correct 87 ms 1784 KB Output is correct
25 Correct 62 ms 1472 KB Output is correct
26 Correct 51 ms 1204 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 392 KB Output is correct
34 Incorrect 0 ms 212 KB Output isn't correct
35 Halted 0 ms 0 KB -