Submission #991162

# Submission time Handle Problem Language Result Execution time Memory
991162 2024-06-01T13:38:40 Z Otalp Self Study (JOI22_ho_t2) C++14
0 / 100
248 ms 5044 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll

ll a[300100];
ll b[300100];
ll  n, m;


bool check(ll x){
    ll h = 0;
    //cout<<x<<' ';
    for(int i=1; i<=n; i++){
        if(a[i] > b[i]){
            if(m * a[i] < x){
                h += m;
                h += (x - m * a[i] - 1) / b[i] + 1;
            }
            else{
                h += (x - 1) / a[i] + 1;
            }
        }
        else{
            h += (x - 1) / b[i] + 1;
        }
    }
    //cout<<h<<'\n';
    return h <= m*n;
}


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 l=0, r=2e18;
    while(l < r){
        ll  mid=(l+r)/2;
        if(check(mid)) l = mid + 1;
        else r = mid;
    } 
    cout<<r - 1;
}


signed main(){
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 248 ms 4948 KB Output is correct
12 Correct 216 ms 5044 KB Output is correct
13 Correct 167 ms 4944 KB Output is correct
14 Incorrect 148 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 89 ms 4536 KB Output is correct
10 Correct 97 ms 4532 KB Output is correct
11 Correct 46 ms 4700 KB Output is correct
12 Correct 59 ms 4688 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 2 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 248 ms 4948 KB Output is correct
12 Correct 216 ms 5044 KB Output is correct
13 Correct 167 ms 4944 KB Output is correct
14 Incorrect 148 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 89 ms 4536 KB Output is correct
10 Correct 97 ms 4532 KB Output is correct
11 Correct 46 ms 4700 KB Output is correct
12 Correct 59 ms 4688 KB Output is correct
13 Correct 1 ms 2648 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Incorrect 2 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 5 ms 2396 KB Output is correct
11 Correct 248 ms 4948 KB Output is correct
12 Correct 216 ms 5044 KB Output is correct
13 Correct 167 ms 4944 KB Output is correct
14 Incorrect 148 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -