답안 #706654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706654 2023-03-07T09:41:11 Z Dan4Life Self Study (JOI22_ho_t2) C++17
0 / 100
474 ms 5068 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 = n*m;
    for(int i = 1; i <= n; i++){
        int num = min((lim+a[i]-1)/a[i], m);
        int x = num*a[i]; tot-=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)2e18;
    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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 234 ms 4996 KB Output is correct
12 Correct 228 ms 5068 KB Output is correct
13 Correct 248 ms 4996 KB Output is correct
14 Incorrect 474 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 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 116 ms 2680 KB Output is correct
10 Correct 80 ms 1884 KB Output is correct
11 Correct 58 ms 1484 KB Output is correct
12 Correct 49 ms 1252 KB Output is correct
13 Correct 1 ms 340 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 0 ms 212 KB Output is correct
18 Incorrect 9 ms 412 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 234 ms 4996 KB Output is correct
12 Correct 228 ms 5068 KB Output is correct
13 Correct 248 ms 4996 KB Output is correct
14 Incorrect 474 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 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 116 ms 2680 KB Output is correct
10 Correct 80 ms 1884 KB Output is correct
11 Correct 58 ms 1484 KB Output is correct
12 Correct 49 ms 1252 KB Output is correct
13 Correct 1 ms 340 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 0 ms 212 KB Output is correct
18 Incorrect 9 ms 412 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 234 ms 4996 KB Output is correct
12 Correct 228 ms 5068 KB Output is correct
13 Correct 248 ms 4996 KB Output is correct
14 Incorrect 474 ms 5004 KB Output isn't correct
15 Halted 0 ms 0 KB -