Submission #1083576

#TimeUsernameProblemLanguageResultExecution timeMemory
1083576HuyATSelf Study (JOI22_ho_t2)C++14
100 / 100
108 ms11344 KiB
#include<bits/stdc++.h> #define newl '\n' const int N = 3e5 + 10; const int V = 1e9 + 10; const long long INF = 1e18; const long long M = 1e9 + 7; long long a[N + 1],b[N + 1],n,m; void readData(){ std::cin >> n >> m; for(int i = 1;i <= n;++i){ std::cin >> a[i]; } for(int i = 1;i <= n;++i){ std::cin >> b[i]; a[i] = std::max(a[i],b[i]); } } bool f(long long mid){ long long s = 0; for(int i = 1;i <= n;++i){ long long t = std::min(m,((mid - 1)) / a[i] + 1); s += t; if(a[i] * t < mid){ s += ((mid - a[i] * t - 1) / b[i] + 1); } if(s > m * n){ return false; } } return true; } long long solve(){ long long lo = 0,hi = 1e18,ans = 0; while(lo <= hi){ long long mid = (lo + hi) / 2; if(f(mid)){ ans = mid; lo = mid + 1; }else{ hi = mid - 1; } } return ans; } int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr);std::cout.tie(nullptr); readData(); std::cout << solve(); return 0; }
#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...