제출 #681488

#제출 시각아이디문제언어결과실행 시간메모리
681488coding_snorlaxSelf Study (JOI22_ho_t2)C++14
100 / 100
442 ms14504 KiB
#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 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...