Submission #706647

# Submission time Handle Problem Language Result Execution time Memory
706647 2023-03-07T09:27:40 Z Dan4Life Self Study (JOI22_ho_t2) C++17
0 / 100
471 ms 10812 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define pb push_back
const int mxN = (int)3e5+10;
int n, m, a[mxN], b[mxN];

bool chk(int lim){
    int tot = 0;
    for(int i = 1; i <= n; i++){
        int num = min((lim+a[i]-1)/a[i], m);
        int x = num*a[i]; tot+=m-num;
        if(lim>=x) tot-=((lim-x)+b[i]-1)/b[i];
    }
    return tot>=0;
}

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], a[i]=max(a[i],b[i]);
    int l = 0, r = (int)1e18;
    while(l<r){
        int mid = (l+r+1)/2;
        if(chk(mid)) l=mid;
        else r=mid-1;
    }
    cout << l;
}

int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
	int t = 1; //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 436 KB Output is correct
11 Correct 227 ms 10744 KB Output is correct
12 Correct 256 ms 10812 KB Output is correct
13 Correct 235 ms 8756 KB Output is correct
14 Incorrect 471 ms 8796 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 117 ms 5548 KB Output is correct
10 Correct 82 ms 3812 KB Output is correct
11 Correct 61 ms 2940 KB Output is correct
12 Correct 51 ms 2420 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 328 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Incorrect 9 ms 424 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 436 KB Output is correct
11 Correct 227 ms 10744 KB Output is correct
12 Correct 256 ms 10812 KB Output is correct
13 Correct 235 ms 8756 KB Output is correct
14 Incorrect 471 ms 8796 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 117 ms 5548 KB Output is correct
10 Correct 82 ms 3812 KB Output is correct
11 Correct 61 ms 2940 KB Output is correct
12 Correct 51 ms 2420 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 328 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Incorrect 9 ms 424 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 436 KB Output is correct
11 Correct 227 ms 10744 KB Output is correct
12 Correct 256 ms 10812 KB Output is correct
13 Correct 235 ms 8756 KB Output is correct
14 Incorrect 471 ms 8796 KB Output isn't correct
15 Halted 0 ms 0 KB -