Submission #636676

# Submission time Handle Problem Language Result Execution time Memory
636676 2022-08-29T22:28:18 Z danikoynov Self Study (JOI22_ho_t2) C++14
54 / 100
393 ms 5136 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];

bool check(ll mf)
{
 ll nec = 0, op = n * m;
            for (int i = 1; i <= n; i ++)
            {
                if (a[i] > b[i])
                {
                    ll loc = mf / a[i];
                    if (mf % a[i] != 0)
                        loc ++;
                    ll to_use = min(m, loc);
                    op = op - to_use;

                    nec = nec + max((ll)0, (mf - to_use * a[i])) / b[i];
                    if ( max((ll)0, (mf - to_use * a[i])) % b[i] != 0)
                        nec ++;


                }
                else
                {
                nec = nec + mf / b[i];
                if (mf % b[i] != 0)
                    nec ++;
                }
                ///cout << i << " " << nec << endl;
            }
        return nec <= op;
}
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;
    }

        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;

            if (check(mf))
                lf = mf + 1;
            else
                rf = mf - 1;
        }
        cout << rf << endl;

}

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

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:58:10: warning: variable 'diff' set but not used [-Wunused-but-set-variable]
   58 |     bool diff = false;
      |          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 1 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 129 ms 2648 KB Output is correct
10 Correct 82 ms 1784 KB Output is correct
11 Correct 64 ms 1472 KB Output is correct
12 Correct 50 ms 1232 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 388 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 76 ms 4900 KB Output is correct
22 Correct 264 ms 4908 KB Output is correct
23 Correct 267 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
6 Correct 1 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 129 ms 2648 KB Output is correct
10 Correct 82 ms 1784 KB Output is correct
11 Correct 64 ms 1472 KB Output is correct
12 Correct 50 ms 1232 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 388 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 76 ms 4900 KB Output is correct
22 Correct 264 ms 4908 KB Output is correct
23 Correct 267 ms 4984 KB Output is correct
24 Correct 52 ms 1092 KB Output is correct
25 Correct 138 ms 2468 KB Output is correct
26 Correct 29 ms 860 KB Output is correct
27 Correct 246 ms 4952 KB Output is correct
28 Correct 252 ms 5008 KB Output is correct
29 Correct 249 ms 4964 KB Output is correct
30 Correct 293 ms 5068 KB Output is correct
31 Correct 359 ms 4988 KB Output is correct
32 Correct 153 ms 5136 KB Output is correct
33 Correct 393 ms 5056 KB Output is correct
34 Correct 187 ms 5024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -