Submission #696219

# Submission time Handle Problem Language Result Execution time Memory
696219 2023-02-05T22:30:59 Z Deepesson Self Study (JOI22_ho_t2) C++17
10 / 100
149 ms 5016 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<<30LL;
    while(l<r){
        ll m=(l+r+1)/2;
        if(possivel(m)){
            l=m;
        }else r=m-1;
    }
    std::cout<<l<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 99 ms 5008 KB Output is correct
12 Correct 100 ms 4932 KB Output is correct
13 Correct 110 ms 5012 KB Output is correct
14 Correct 125 ms 5000 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 149 ms 5016 KB Output is correct
17 Correct 127 ms 4928 KB Output is correct
18 Correct 98 ms 5000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 149 ms 5016 KB Output is correct
3 Correct 127 ms 4928 KB Output is correct
4 Correct 98 ms 5000 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 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 99 ms 5008 KB Output is correct
12 Correct 100 ms 4932 KB Output is correct
13 Correct 110 ms 5012 KB Output is correct
14 Correct 125 ms 5000 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 0 ms 212 KB Output isn't correct
19 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 Incorrect 0 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 99 ms 5008 KB Output is correct
12 Correct 100 ms 4932 KB Output is correct
13 Correct 110 ms 5012 KB Output is correct
14 Correct 125 ms 5000 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 0 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -