Submission #1018791

# Submission time Handle Problem Language Result Execution time Memory
1018791 2024-07-10T09:48:19 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
120 ms 4956 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define tobit(n) bitset<20>(n) //выводит 20 элементов в битовую систему
#define all(v) (v).begin(), (v).end() 
#define rtt(v, k) rotate(v.begin(), v.begin() + k, v.end()); //move k elements back
signed main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    for(auto &to : a) cin >> to;
    for(auto &to : b) cin >> to;
    int l = 0; int r = 1e18 + 6;
    auto check = [&](int p){
        int t = 0;
        for(int i = 0; i < n; i++){
            if(b[i] > a[i]){
                int b_ = (p + b[i] - 1) / b[i];
                t += b_;
            } else {
                if(a[i] * 1ll * m >= p){
                    int a_ = (p + a[i] - 1) / a[i]; t += a_;
                } else {
                    int a_ = m;
                    int b_ = (p - a[i] * 1ll * a_ + b[i] - 1) / b[i]; t += a_ + b_;
                }
            }
        } if(t <= n * 1ll * m) return true;
        else return false;
    };
    while(r > l + 1){
        int m = (l + r) / 2;
        if(check(m)) l = m;
        else r = m;
    } if(check(r)){
        cout << r;
    } else {
        cout << l;
    }
}
// NEED TO FAST CIN && COUT //
const int fastIO = [](){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    return 0;
}();
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 118 ms 4956 KB Output is correct
12 Correct 120 ms 4952 KB Output is correct
13 Correct 71 ms 4956 KB Output is correct
14 Incorrect 84 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 41 ms 2652 KB Output is correct
10 Correct 27 ms 2136 KB Output is correct
11 Correct 20 ms 1624 KB Output is correct
12 Correct 16 ms 1412 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 1 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 118 ms 4956 KB Output is correct
12 Correct 120 ms 4952 KB Output is correct
13 Correct 71 ms 4956 KB Output is correct
14 Incorrect 84 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 41 ms 2652 KB Output is correct
10 Correct 27 ms 2136 KB Output is correct
11 Correct 20 ms 1624 KB Output is correct
12 Correct 16 ms 1412 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 1 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 118 ms 4956 KB Output is correct
12 Correct 120 ms 4952 KB Output is correct
13 Correct 71 ms 4956 KB Output is correct
14 Incorrect 84 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -