Submission #1018786

# Submission time Handle Problem Language Result Execution time Memory
1018786 2024-07-10T09:46:49 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
134 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;
    } 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 123 ms 4956 KB Output is correct
12 Correct 134 ms 4952 KB Output is correct
13 Correct 73 ms 4956 KB Output is correct
14 Incorrect 83 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 2036 KB Output is correct
11 Correct 21 ms 1640 KB Output is correct
12 Correct 17 ms 1372 KB Output is correct
13 Correct 0 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 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 123 ms 4956 KB Output is correct
12 Correct 134 ms 4952 KB Output is correct
13 Correct 73 ms 4956 KB Output is correct
14 Incorrect 83 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 2036 KB Output is correct
11 Correct 21 ms 1640 KB Output is correct
12 Correct 17 ms 1372 KB Output is correct
13 Correct 0 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 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 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 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 123 ms 4956 KB Output is correct
12 Correct 134 ms 4952 KB Output is correct
13 Correct 73 ms 4956 KB Output is correct
14 Incorrect 83 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -