Submission #696220

# Submission time Handle Problem Language Result Execution time Memory
696220 2023-02-05T22:32:56 Z Deepesson Self Study (JOI22_ho_t2) C++17
0 / 100
466 ms 5012 KB
#include <bits/stdc++.h>
#define MAX 305000

using ll = long long;
ll A[MAX],B[MAX];
ll N,M;

ll teto(ll a,ll b){
    ll c = a/b;
    if(a%b)++c;
    return c;
}

bool possivel(ll x){
    ll sum=0;
    for(int i=0;i!=N;++i){
        ll necessario = teto(x,A[i]);
        ll gastar = std::min(necessario,M);
        ll falta = x-(gastar*A[i]);
        if(falta>0){
            ll precisa = teto(falta,B[i]);
            sum-=precisa;
        }else {
            ll sobra = M-gastar;
            sum+=sobra;
        }
    }
    return sum>=0;
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    std::cin>>N>>M;
    for(int i=0;i!=N;++i)std::cin>>A[i];
    for(int i=0;i!=N;++i)std::cin>>B[i];
    for(int i=0;i!=N;++i){
        if(A[i]<B[i]){
            A[i]=B[i];
        }
    }

    ll l=1,r=1LL<<60LL;
    while(l<r){
        ll m=(r-l+1)/2+l;
        if(possivel(m)){
            l=m;
        }else r=m-1;
    }
    std::cout<<l<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 224 ms 5012 KB Output is correct
12 Correct 222 ms 5012 KB Output is correct
13 Correct 235 ms 4940 KB Output is correct
14 Incorrect 466 ms 5008 KB Output isn't correct
15 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 119 ms 2672 KB Output is correct
10 Correct 76 ms 1900 KB Output is correct
11 Correct 57 ms 1496 KB Output is correct
12 Correct 48 ms 1260 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 8 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 224 ms 5012 KB Output is correct
12 Correct 222 ms 5012 KB Output is correct
13 Correct 235 ms 4940 KB Output is correct
14 Incorrect 466 ms 5008 KB Output isn't correct
15 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 119 ms 2672 KB Output is correct
10 Correct 76 ms 1900 KB Output is correct
11 Correct 57 ms 1496 KB Output is correct
12 Correct 48 ms 1260 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 8 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 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 340 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 224 ms 5012 KB Output is correct
12 Correct 222 ms 5012 KB Output is correct
13 Correct 235 ms 4940 KB Output is correct
14 Incorrect 466 ms 5008 KB Output isn't correct
15 Halted 0 ms 0 KB -