답안 #636683

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636683 2022-08-29T22:36:32 Z danikoynov Self Study (JOI22_ho_t2) C++14
100 / 100
418 ms 10852 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;
    }
    ll m1 = 1e18;
    for (int i = 1; i <= n; i ++)
        m1=  min(m1, max(a[i], b[i]));

        double sum = 0;
        for (int i = 1; i <= n; i ++)
            sum = sum + (double)m / (double)(n) * (double)max(a[i], b[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:68:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   68 |     for (int i = 1; i <= n; i ++)
      |     ^~~
Main.cpp:71:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   71 |         double sum = 0;
      |         ^~~~~~
Main.cpp:58:10: warning: variable 'diff' set but not used [-Wunused-but-set-variable]
   58 |     bool diff = false;
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 259 ms 5028 KB Output is correct
12 Correct 248 ms 5088 KB Output is correct
13 Correct 207 ms 5016 KB Output is correct
14 Correct 194 ms 4984 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 75 ms 4904 KB Output is correct
17 Correct 265 ms 4980 KB Output is correct
18 Correct 250 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 75 ms 4904 KB Output is correct
3 Correct 265 ms 4980 KB Output is correct
4 Correct 250 ms 4944 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 1 ms 212 KB Output is correct
10 Correct 1 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 135 ms 2732 KB Output is correct
14 Correct 86 ms 1868 KB Output is correct
15 Correct 64 ms 1356 KB Output is correct
16 Correct 52 ms 1240 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 1 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 259 ms 5028 KB Output is correct
12 Correct 248 ms 5088 KB Output is correct
13 Correct 207 ms 5016 KB Output is correct
14 Correct 194 ms 4984 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 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 135 ms 2732 KB Output is correct
24 Correct 86 ms 1868 KB Output is correct
25 Correct 64 ms 1356 KB Output is correct
26 Correct 52 ms 1240 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 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 75 ms 4904 KB Output is correct
36 Correct 265 ms 4980 KB Output is correct
37 Correct 250 ms 4944 KB Output is correct
38 Correct 1 ms 304 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 5 ms 444 KB Output is correct
46 Correct 8 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 46 ms 1996 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 127 ms 5452 KB Output is correct
56 Correct 65 ms 3132 KB Output is correct
57 Correct 66 ms 3124 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 135 ms 2732 KB Output is correct
10 Correct 86 ms 1868 KB Output is correct
11 Correct 64 ms 1356 KB Output is correct
12 Correct 52 ms 1240 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 1 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 75 ms 4904 KB Output is correct
22 Correct 265 ms 4980 KB Output is correct
23 Correct 250 ms 4944 KB Output is correct
24 Correct 57 ms 1020 KB Output is correct
25 Correct 153 ms 2296 KB Output is correct
26 Correct 30 ms 796 KB Output is correct
27 Correct 246 ms 5052 KB Output is correct
28 Correct 258 ms 4872 KB Output is correct
29 Correct 262 ms 4940 KB Output is correct
30 Correct 287 ms 4976 KB Output is correct
31 Correct 376 ms 5080 KB Output is correct
32 Correct 154 ms 4860 KB Output is correct
33 Correct 418 ms 4984 KB Output is correct
34 Correct 263 ms 5216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 259 ms 5028 KB Output is correct
12 Correct 248 ms 5088 KB Output is correct
13 Correct 207 ms 5016 KB Output is correct
14 Correct 194 ms 4984 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 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 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 135 ms 2732 KB Output is correct
24 Correct 86 ms 1868 KB Output is correct
25 Correct 64 ms 1356 KB Output is correct
26 Correct 52 ms 1240 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 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 1 ms 304 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 444 KB Output is correct
42 Correct 8 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 46 ms 1996 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 ms 468 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 127 ms 5452 KB Output is correct
52 Correct 65 ms 3132 KB Output is correct
53 Correct 66 ms 3124 KB Output is correct
54 Correct 57 ms 1020 KB Output is correct
55 Correct 153 ms 2296 KB Output is correct
56 Correct 30 ms 796 KB Output is correct
57 Correct 246 ms 5052 KB Output is correct
58 Correct 258 ms 4872 KB Output is correct
59 Correct 262 ms 4940 KB Output is correct
60 Correct 287 ms 4976 KB Output is correct
61 Correct 376 ms 5080 KB Output is correct
62 Correct 154 ms 4860 KB Output is correct
63 Correct 418 ms 4984 KB Output is correct
64 Correct 263 ms 5216 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 75 ms 4904 KB Output is correct
67 Correct 265 ms 4980 KB Output is correct
68 Correct 250 ms 4944 KB Output is correct
69 Correct 42 ms 1364 KB Output is correct
70 Correct 11 ms 576 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 62 ms 1808 KB Output is correct
73 Correct 12 ms 596 KB Output is correct
74 Correct 2 ms 332 KB Output is correct
75 Correct 263 ms 10852 KB Output is correct
76 Correct 285 ms 10700 KB Output is correct
77 Correct 284 ms 10836 KB Output is correct
78 Correct 321 ms 10708 KB Output is correct
79 Correct 373 ms 10780 KB Output is correct
80 Correct 382 ms 10668 KB Output is correct
81 Correct 322 ms 8760 KB Output is correct
82 Correct 340 ms 8852 KB Output is correct