답안 #706653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706653 2023-03-07T09:39:09 Z Dan4Life Self Study (JOI22_ho_t2) C++17
0 / 100
456 ms 5000 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)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();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 0 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 218 ms 5000 KB Output is correct
12 Correct 221 ms 5000 KB Output is correct
13 Correct 238 ms 4996 KB Output is correct
14 Incorrect 456 ms 4940 KB Output isn't correct
15 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 114 ms 2592 KB Output is correct
10 Correct 76 ms 1848 KB Output is correct
11 Correct 56 ms 1484 KB Output is correct
12 Correct 47 ms 1260 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 340 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 0 ms 212 KB Output is correct
4 Correct 1 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 0 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 218 ms 5000 KB Output is correct
12 Correct 221 ms 5000 KB Output is correct
13 Correct 238 ms 4996 KB Output is correct
14 Incorrect 456 ms 4940 KB Output isn't correct
15 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 114 ms 2592 KB Output is correct
10 Correct 76 ms 1848 KB Output is correct
11 Correct 56 ms 1484 KB Output is correct
12 Correct 47 ms 1260 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 340 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 0 ms 212 KB Output is correct
4 Correct 1 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 0 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 218 ms 5000 KB Output is correct
12 Correct 221 ms 5000 KB Output is correct
13 Correct 238 ms 4996 KB Output is correct
14 Incorrect 456 ms 4940 KB Output isn't correct
15 Halted 0 ms 0 KB -