Submission #534171

# Submission time Handle Problem Language Result Execution time Memory
534171 2022-03-08T01:49:14 Z LittleOrange Self Study (JOI22_ho_t2) C++17
0 / 100
343 ms 4940 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m;
vector<pair<ll,ll> > dat;
bool isok(ll target){ // ans>=target;
    ll time = 0;
    for (ll i = 0;i<n;i++){
        ll a = m;
        ll t = target - a*dat[i].first;
        if (t<=-dat[i].first){
            a -= (-t)/dat[i].first;
            t = target - a*dat[i].first;
        }else if (t>0){
            a += t/dat[i].second;
            t -= t/dat[i].second*dat[i].second;
            if (t>0){
                a++;
            }
        }
        time += a;
    }
    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;
    dat.resize(n);
    for (ll i = 0;i<n;i++){
        cin >> dat[i].first;
    }
    for (ll i = 0;i<n;i++){
        cin >> dat[i].second;
        dat[i].first = max(dat[i].first, dat[i].second);
    }
    cout << check(0,5e18) << "\n";
}
# 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 0 ms 204 KB Output is correct
4 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 172 ms 4940 KB Output is correct
12 Correct 139 ms 4940 KB Output is correct
13 Correct 161 ms 4940 KB Output is correct
14 Incorrect 343 ms 4940 KB Output isn't correct
15 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 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 92 ms 2660 KB Output is correct
10 Correct 60 ms 1868 KB Output is correct
11 Correct 43 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 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 5 ms 332 KB Output isn't correct
19 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 0 ms 204 KB Output is correct
4 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 172 ms 4940 KB Output is correct
12 Correct 139 ms 4940 KB Output is correct
13 Correct 161 ms 4940 KB Output is correct
14 Incorrect 343 ms 4940 KB Output isn't correct
15 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 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 92 ms 2660 KB Output is correct
10 Correct 60 ms 1868 KB Output is correct
11 Correct 43 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 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 5 ms 332 KB Output isn't correct
19 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 0 ms 204 KB Output is correct
4 Correct 1 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 0 ms 204 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 172 ms 4940 KB Output is correct
12 Correct 139 ms 4940 KB Output is correct
13 Correct 161 ms 4940 KB Output is correct
14 Incorrect 343 ms 4940 KB Output isn't correct
15 Halted 0 ms 0 KB -