Submission #887706

#TimeUsernameProblemLanguageResultExecution timeMemory
887706Maite_MoraleSelf Study (JOI22_ho_t2)C++14
0 / 100
476 ms6780 KiB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 500005
#define oo 1e19
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>
 
ll n,k;
pll a[MAX];
ll OK(ll x){
    ll m=k*n,r=0;
    for(int i=0;i<n;i++){
        ll moves=min(k,(x+a[i].F-1)/a[i].F);
        r+=(max((ll)0,x-(a[i].F*moves))+a[i].S-1)/a[i].S;
        m-=moves;
    }
    if(r<=m)return 1;
return 0;
}
int main(){
    fast_in
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i].F;
    }
    for(int i=0;i<n;i++){
        cin>>a[i].S;a[i].F=max(a[i].S,a[i].F);
    }
    ll p=0,f=oo;
    while(abs(p-f)!=1){
        ll m=(p+f)/2;
        if(OK(m)==1)p=m;
        else        f=m;
    }
    cout<<p;
return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:5:12: warning: overflow in conversion from 'double' to 'll' {aka 'long long int'} changes value from '1.0e+19' to '9223372036854775807' [-Woverflow]
    5 | #define oo 1e19
      |            ^~~~
Main.cpp:36:14: note: in expansion of macro 'oo'
   36 |     ll p=0,f=oo;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...