이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
long long int N,M,Count,Total_time,tmp;
vector<long long int> List;
vector<long long int> List_2;
int check(long long int x){
//cout<<x<<"\n";
long long int Free = 0, Ask = 0;
for(int i=0;i<(int)List.size();i++){
if(List[i]<List_2[i]){
Free += M;
if(!(x%List_2[i])) Ask += x/List_2[i];
else Ask += x/List_2[i]+1;
if(Ask < 0) return 0;
}
else{
long long int Add=0
;
if(!(x%List[i])) Add = x/List[i];
else Add += x/List[i]+1;
if(Add<=M){
Free += M-Add;
}
else{
if(!((x-List[i]*M)%List_2[i])) Ask += (x-List[i]*M)/List_2[i];
else Ask += (x-List[i]*M)/List_2[i]+1;
}
if(Ask < 0) return 0;
}
}
if(Ask>Free) return 0;
else return 1;
/*
cout<<x<<" ";
int Back;
cin>>Back;
return Back;
*/
}
int main(){
cin>>N>>M;
for(int i=1;i<=N;i++){
cin>>tmp;
List.push_back(tmp);
}
for(int i=1;i<=N;i++){
cin>>tmp;
List_2.push_back(tmp);
}
Total_time=N*M;
long long int L = 0,R = 2000000000000000003;
while(L!=R){
long long int M = (L+R)/2+1;
if(check(M)) L=M;
else R=M-1;
}
cout<<L;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |