Submission #753797

# Submission time Handle Problem Language Result Execution time Memory
753797 2023-06-06T04:59:05 Z bgnbvnbv Self Study (JOI22_ho_t2) C++14
100 / 100
306 ms 11340 KB
#include<bits/stdc++.h>
#define TASKNAME "codeforce"
#define pb push_back
#define pli pair<int,int>
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
using ll=long long;
const ll maxN=3e5+10;
const ll inf=1e18;
const ll mod=1e9+7;
ll a[maxN],b[maxN];
ll n,m;
bool check(ll mid)
{
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        ll cc=max(a[i],b[i]);
        cc=(mid+cc-1)/cc;
        if(cc<=m) sum+=m-cc;
        else
        {
            cc=max(a[i],b[i]);
            ll can=mid-cc*m;
            can=(can+b[i]-1)/b[i];
            sum-=can;
            if(sum<-m*n) return false;
        }
        // cc*...>=mid
    }
    return sum>=0;
}
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
#define rand rd
void solve()
{

        cin >> n >> m;
        for(int i=1;i<=n;i++)
        {

            cin >> a[i];
        }
        for(int i=1;i<=n;i++)
        {
            cin >> b[i];
        }

        ll low=0,high=5e18;
        ll ans=inf;
        for(int i=1;i<=n;i++)
        {
            ans=min(ans,max(a[i],b[i]));
        }
        while(low<=high)
        {
            ll mid=low+high>>1;
            if(check(mid)) low=mid+1;
            else high=mid-1;
        }
        cout << high;


}
int main()
{
    fastio
    //freopen(TASKNAME".INP","r",stdin);
    //freopen(TASKNAME".OUT","w",stdout);
    solve();
}

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:59:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   59 |             ll mid=low+high>>1;
      |                    ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 116 ms 10796 KB Output is correct
12 Correct 110 ms 10792 KB Output is correct
13 Correct 113 ms 8816 KB Output is correct
14 Correct 88 ms 8792 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 40 ms 6088 KB Output is correct
17 Correct 168 ms 11332 KB Output is correct
18 Correct 103 ms 10760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 40 ms 6088 KB Output is correct
3 Correct 168 ms 11332 KB Output is correct
4 Correct 103 ms 10760 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 54 ms 5452 KB Output is correct
14 Correct 35 ms 3708 KB Output is correct
15 Correct 27 ms 2892 KB Output is correct
16 Correct 23 ms 2388 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 116 ms 10796 KB Output is correct
12 Correct 110 ms 10792 KB Output is correct
13 Correct 113 ms 8816 KB Output is correct
14 Correct 88 ms 8792 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 54 ms 5452 KB Output is correct
24 Correct 35 ms 3708 KB Output is correct
25 Correct 27 ms 2892 KB Output is correct
26 Correct 23 ms 2388 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 40 ms 6088 KB Output is correct
36 Correct 168 ms 11332 KB Output is correct
37 Correct 103 ms 10760 KB Output is correct
38 Correct 1 ms 328 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 328 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 4 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 21 ms 2132 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 3 ms 468 KB Output is correct
52 Correct 1 ms 328 KB Output is correct
53 Correct 1 ms 340 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 57 ms 5520 KB Output is correct
56 Correct 43 ms 3136 KB Output is correct
57 Correct 28 ms 3140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 54 ms 5452 KB Output is correct
10 Correct 35 ms 3708 KB Output is correct
11 Correct 27 ms 2892 KB Output is correct
12 Correct 23 ms 2388 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 468 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 40 ms 6088 KB Output is correct
22 Correct 168 ms 11332 KB Output is correct
23 Correct 103 ms 10760 KB Output is correct
24 Correct 37 ms 1944 KB Output is correct
25 Correct 87 ms 5120 KB Output is correct
26 Correct 16 ms 1348 KB Output is correct
27 Correct 104 ms 10768 KB Output is correct
28 Correct 115 ms 10808 KB Output is correct
29 Correct 114 ms 10764 KB Output is correct
30 Correct 137 ms 10764 KB Output is correct
31 Correct 228 ms 10772 KB Output is correct
32 Correct 144 ms 6180 KB Output is correct
33 Correct 306 ms 11340 KB Output is correct
34 Correct 169 ms 6056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 116 ms 10796 KB Output is correct
12 Correct 110 ms 10792 KB Output is correct
13 Correct 113 ms 8816 KB Output is correct
14 Correct 88 ms 8792 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 332 KB Output is correct
23 Correct 54 ms 5452 KB Output is correct
24 Correct 35 ms 3708 KB Output is correct
25 Correct 27 ms 2892 KB Output is correct
26 Correct 23 ms 2388 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 468 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 328 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 3 ms 468 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 21 ms 2132 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 340 KB Output is correct
47 Correct 3 ms 468 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 1 ms 340 KB Output is correct
51 Correct 57 ms 5520 KB Output is correct
52 Correct 43 ms 3136 KB Output is correct
53 Correct 28 ms 3140 KB Output is correct
54 Correct 37 ms 1944 KB Output is correct
55 Correct 87 ms 5120 KB Output is correct
56 Correct 16 ms 1348 KB Output is correct
57 Correct 104 ms 10768 KB Output is correct
58 Correct 115 ms 10808 KB Output is correct
59 Correct 114 ms 10764 KB Output is correct
60 Correct 137 ms 10764 KB Output is correct
61 Correct 228 ms 10772 KB Output is correct
62 Correct 144 ms 6180 KB Output is correct
63 Correct 306 ms 11340 KB Output is correct
64 Correct 169 ms 6056 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 40 ms 6088 KB Output is correct
67 Correct 168 ms 11332 KB Output is correct
68 Correct 103 ms 10760 KB Output is correct
69 Correct 24 ms 1364 KB Output is correct
70 Correct 7 ms 596 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 38 ms 1748 KB Output is correct
73 Correct 10 ms 596 KB Output is correct
74 Correct 1 ms 468 KB Output is correct
75 Correct 131 ms 10744 KB Output is correct
76 Correct 148 ms 10700 KB Output is correct
77 Correct 144 ms 10812 KB Output is correct
78 Correct 205 ms 10816 KB Output is correct
79 Correct 246 ms 10816 KB Output is correct
80 Correct 250 ms 10700 KB Output is correct
81 Correct 281 ms 8704 KB Output is correct
82 Correct 225 ms 8828 KB Output is correct