Submission #914968

# Submission time Handle Problem Language Result Execution time Memory
914968 2024-01-23T03:32:43 Z ReLice Self Study (JOI22_ho_t2) C++14
0 / 100
439 ms 8196 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
    bool f=0;
    if (x>y){x=y;f=1;}
    return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool f=0;
    if (x<y){x=y;f=1;}
    return f;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
void solve(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    ll a[n],b[n];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++){
        cin>>b[i];
        if(b[i]>a[i])a[i]=b[i];
    }
    ll l=1,r=2*inf;
    while(l+1<r){
        ll mid=(l+r)/2;
        ll sum=0;
        for(i=0;i<n;i++){
            ll in=(mid+a[i]-1)/a[i];
            if(in>m){
                in=m;
                ll out=(mid-a[i]*in+b[i]-1)/b[i];
                sum+=out;
            }
            sum+=in;
        }
        if(sum<=n*m)l=mid;
        else r=mid;
    }
    cout<<l<<endl;
}

signed main(){
	start();
    ll t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}
/*



*/

Compilation message

Main.cpp: In function 'void solve()':
Main.cpp:46:10: warning: unused variable 'j' [-Wunused-variable]
   46 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 600 KB Output is correct
11 Correct 212 ms 7984 KB Output is correct
12 Correct 214 ms 8196 KB Output is correct
13 Correct 217 ms 6992 KB Output is correct
14 Incorrect 439 ms 7248 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 108 ms 2776 KB Output is correct
10 Correct 71 ms 1880 KB Output is correct
11 Correct 53 ms 1624 KB Output is correct
12 Correct 44 ms 1372 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Incorrect 9 ms 528 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 600 KB Output is correct
11 Correct 212 ms 7984 KB Output is correct
12 Correct 214 ms 8196 KB Output is correct
13 Correct 217 ms 6992 KB Output is correct
14 Incorrect 439 ms 7248 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 108 ms 2776 KB Output is correct
10 Correct 71 ms 1880 KB Output is correct
11 Correct 53 ms 1624 KB Output is correct
12 Correct 44 ms 1372 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Incorrect 9 ms 528 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 652 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 600 KB Output is correct
11 Correct 212 ms 7984 KB Output is correct
12 Correct 214 ms 8196 KB Output is correct
13 Correct 217 ms 6992 KB Output is correct
14 Incorrect 439 ms 7248 KB Output isn't correct
15 Halted 0 ms 0 KB -