답안 #1018801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018801 2024-07-10T09:52:16 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
123 ms 5112 KB
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define ROF(i,m,n) for(int i=m;i<=n;i++)
#define vi vector<int>
#define pb push_back
#define alle(a) a.begin(),a.end()
#define rall(n) rbegin(n),rend(n)
#define int long long
#define vecs vector<int> 
#define ll long long
#define ss second 
#define ff first
const int INF = 1e9;
const int MOD = 1e9 + 7;
void solve(){
    int n , m;
    cin>>n>>m;
    vector <int> a(n);
    for(int i = 0;i < n;i++){
        cin>>a[i];
    }
    vector <int> b(n);
    for(int i = 0;i < n;i++){
        cin>>b[i];
    }
    auto check = [&](int m1){
        int ans = 0;
        int b1 = 0;
        int a1 = 0;
        for(int i = 0;i < n;i++){
            a1 = 0;
            b1 = 0;
            if(a[i] <= b[i]){
                b1 += (m1 + b[i] - 1) / b[i];
            }
            if(a[i] > b[i]){
                int f = a[i] * m;
                if(f >= m1){
                    a1 += (m1 + a[i] - 1)/ a[i];
                }
                else{
                    a1 += m;
                    b1 += (m1 - f + b[i] - 1)/b[i];
                }
            }
            ans += b1;
            ans += a1;
        }
        if(ans <= m * n){
            return true;
        }
        else{
            return false;
        }
    };
    int l = 1, r = 1e18 + 1;
    while(1 <  r - l){
        int m2 =  (r + l) >> 1;
        if(check( m2 )){
            l = m2;
        }
        else{
            r = m2;
        }
    }
    if(check(r)){
        cout<<r;
    }
    else{
        cout<<l;
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int ti = 1;
    while (ti--) {
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 122 ms 4952 KB Output is correct
12 Correct 123 ms 4944 KB Output is correct
13 Correct 101 ms 4948 KB Output is correct
14 Incorrect 85 ms 5112 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 41 ms 2668 KB Output is correct
10 Correct 28 ms 1880 KB Output is correct
11 Correct 21 ms 1628 KB Output is correct
12 Correct 17 ms 1372 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 122 ms 4952 KB Output is correct
12 Correct 123 ms 4944 KB Output is correct
13 Correct 101 ms 4948 KB Output is correct
14 Incorrect 85 ms 5112 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 41 ms 2668 KB Output is correct
10 Correct 28 ms 1880 KB Output is correct
11 Correct 21 ms 1628 KB Output is correct
12 Correct 17 ms 1372 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 532 KB Output is correct
11 Correct 122 ms 4952 KB Output is correct
12 Correct 123 ms 4944 KB Output is correct
13 Correct 101 ms 4948 KB Output is correct
14 Incorrect 85 ms 5112 KB Output isn't correct
15 Halted 0 ms 0 KB -