Submission #938095

#TimeUsernameProblemLanguageResultExecution timeMemory
938095esomerSelf Study (JOI22_ho_t2)C++17
100 / 100
223 ms8784 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); long long N, M; cin >> N >> M; vector<int> A(N); for(auto &i : A) cin >> i; vector<int> B(N); for(auto &i : B) cin >> i; long long lo = 0; long long hi = 1e18; long long bst = 0; while(lo <= hi){ long long mid = (lo + hi) / 2; long long need = 0; for(int i = 0; i < N && need <= N * M; i++){ long long needClass = (mid + max(A[i], B[i]) - 1) / max(A[i], B[i]); if(needClass <= M){ need += needClass; continue; } need += M; long long left = mid - max(A[i], B[i]) * M; need += (left + B[i] - 1) / B[i]; } if(need <= N*M){ bst = mid; lo = mid + 1; }else hi = mid - 1; } cout << bst << "\n"; }
#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...