Submission #706650

# Submission time Handle Problem Language Result Execution time Memory
706650 2023-03-07T09:35:44 Z Dan4Life Self Study (JOI22_ho_t2) C++17
0 / 100
463 ms 5244 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;
    }
    for(int i = l; i<=l+2; i++){
        if(chk(i)){cout<<i;return;}
    }
    //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 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 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 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 222 ms 5020 KB Output is correct
12 Correct 225 ms 5040 KB Output is correct
13 Correct 236 ms 5244 KB Output is correct
14 Incorrect 463 ms 5124 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 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 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 116 ms 2772 KB Output is correct
10 Correct 78 ms 2012 KB Output is correct
11 Correct 58 ms 1616 KB Output is correct
12 Correct 48 ms 1364 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 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Incorrect 9 ms 340 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 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 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 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 222 ms 5020 KB Output is correct
12 Correct 225 ms 5040 KB Output is correct
13 Correct 236 ms 5244 KB Output is correct
14 Incorrect 463 ms 5124 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 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 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 116 ms 2772 KB Output is correct
10 Correct 78 ms 2012 KB Output is correct
11 Correct 58 ms 1616 KB Output is correct
12 Correct 48 ms 1364 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 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 320 KB Output is correct
18 Incorrect 9 ms 340 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 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 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 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 222 ms 5020 KB Output is correct
12 Correct 225 ms 5040 KB Output is correct
13 Correct 236 ms 5244 KB Output is correct
14 Incorrect 463 ms 5124 KB Output isn't correct
15 Halted 0 ms 0 KB -