답안 #636677

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636677 2022-08-29T22:28:58 Z danikoynov Self Study (JOI22_ho_t2) C++14
54 / 100
405 ms 5088 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;
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 134 ms 2732 KB Output is correct
10 Correct 88 ms 1784 KB Output is correct
11 Correct 64 ms 1464 KB Output is correct
12 Correct 62 ms 1176 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 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 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 94 ms 4968 KB Output is correct
22 Correct 266 ms 4940 KB Output is correct
23 Correct 247 ms 4928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 134 ms 2732 KB Output is correct
10 Correct 88 ms 1784 KB Output is correct
11 Correct 64 ms 1464 KB Output is correct
12 Correct 62 ms 1176 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 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 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 94 ms 4968 KB Output is correct
22 Correct 266 ms 4940 KB Output is correct
23 Correct 247 ms 4928 KB Output is correct
24 Correct 55 ms 1020 KB Output is correct
25 Correct 151 ms 2392 KB Output is correct
26 Correct 31 ms 808 KB Output is correct
27 Correct 259 ms 4888 KB Output is correct
28 Correct 257 ms 5012 KB Output is correct
29 Correct 264 ms 4976 KB Output is correct
30 Correct 285 ms 4980 KB Output is correct
31 Correct 372 ms 5088 KB Output is correct
32 Correct 168 ms 4980 KB Output is correct
33 Correct 405 ms 4944 KB Output is correct
34 Correct 260 ms 5008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -