Submission #534183

# Submission time Handle Problem Language Result Execution time Memory
534183 2022-03-08T01:54:01 Z LittleOrange Self Study (JOI22_ho_t2) C++17
0 / 100
324 ms 5000 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector<ll> a,b;
bool isok(ll target){ // ans>=target;
    ll time = 0;
    for (ll i = 0;i<n;i++){
        ll x = m;
        ll t = target - x*a[i];
        if (t<=-a[i]){
            x -= (-t)/a[i];
            t = target - x*a[i];
        }else if (t>0){
            x += t/b[i];
            t -= (t/b[i])*b[i];
            while (t>0){
                x++;
                t-=b[i];
            }
        }
        time += x;
    }
    return time<=n*m;
}
ll check(ll l, ll r){
    if (l >= r) return l;
    ll mid = (l+r)/2;
    if (isok(mid+1)){
        return check(mid+1,r);
    }else{
        return check(l,mid);
    }
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> m;
    a.resize(n,0);
    b.resize(n,0);
    for (ll i = 0;i<n;i++){
        cin >> a[i];
    }
    for (ll i = 0;i<n;i++){
        cin >> b[i];
        a[i] = max(a[i], b[i]);
    }
    cout << check(0,5e18) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 139 ms 5000 KB Output is correct
12 Correct 137 ms 4996 KB Output is correct
13 Correct 140 ms 4940 KB Output is correct
14 Incorrect 324 ms 5000 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 93 ms 2656 KB Output is correct
10 Correct 58 ms 1868 KB Output is correct
11 Correct 45 ms 1484 KB Output is correct
12 Correct 36 ms 1228 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 6 ms 380 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 139 ms 5000 KB Output is correct
12 Correct 137 ms 4996 KB Output is correct
13 Correct 140 ms 4940 KB Output is correct
14 Incorrect 324 ms 5000 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 93 ms 2656 KB Output is correct
10 Correct 58 ms 1868 KB Output is correct
11 Correct 45 ms 1484 KB Output is correct
12 Correct 36 ms 1228 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 6 ms 380 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 139 ms 5000 KB Output is correct
12 Correct 137 ms 4996 KB Output is correct
13 Correct 140 ms 4940 KB Output is correct
14 Incorrect 324 ms 5000 KB Output isn't correct
15 Halted 0 ms 0 KB -