Submission #551444

# Submission time Handle Problem Language Result Execution time Memory
551444 2022-04-20T17:35:51 Z Ronin13 Self Study (JOI22_ho_t2) C++14
0 / 100
508 ms 5000 KB
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;

const ll linf = 1e18 + 1;

bool check(ll a[], ll b[], ll x, ll n, ll m){
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        ll cnta;
        if(b[i] >= a[i])cnta = 0;
        else{
            cnta = x / a[i];
            if(x % a[i]) cnta++;
            cnta = min(cnta, m);
        }
        ll cur = x - a[i] * cnta;
        cnt += cnta;
        if(cur < 0) continue;
        else{
            cnt += cur / b[i];
            if(cur % b[i])cnt++;
        }
    }
    return cnt <= n * m;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll n; cin >> n;
    ll m; cin >> m;
    ll a[n + 1];
    ll b[n + 1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
    }
    ll l = 0, r = linf;
    while(l + 1 < r){
        ll mid = (l + r) / 2;
        if(check(a, b, mid, n, m))l = mid;
        else r = mid;
    }
    cout << l;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 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 1 ms 212 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 209 ms 5000 KB Output is correct
12 Correct 225 ms 4948 KB Output is correct
13 Correct 156 ms 4948 KB Output is correct
14 Incorrect 508 ms 4996 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 1 ms 212 KB Output is correct
9 Correct 85 ms 2648 KB Output is correct
10 Correct 57 ms 1876 KB Output is correct
11 Correct 43 ms 1364 KB Output is correct
12 Correct 35 ms 1236 KB Output is correct
13 Correct 1 ms 212 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 5 ms 392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 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 1 ms 212 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 209 ms 5000 KB Output is correct
12 Correct 225 ms 4948 KB Output is correct
13 Correct 156 ms 4948 KB Output is correct
14 Incorrect 508 ms 4996 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 1 ms 212 KB Output is correct
9 Correct 85 ms 2648 KB Output is correct
10 Correct 57 ms 1876 KB Output is correct
11 Correct 43 ms 1364 KB Output is correct
12 Correct 35 ms 1236 KB Output is correct
13 Correct 1 ms 212 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 5 ms 392 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 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 1 ms 212 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 209 ms 5000 KB Output is correct
12 Correct 225 ms 4948 KB Output is correct
13 Correct 156 ms 4948 KB Output is correct
14 Incorrect 508 ms 4996 KB Output isn't correct
15 Halted 0 ms 0 KB -