Submission #1057654

#TimeUsernameProblemLanguageResultExecution timeMemory
1057654Roumak77Self Study (JOI22_ho_t2)C++17
0 / 100
1 ms348 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <vector> #include <limits> #include <cmath> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; using ll = long long; void solve(){ ll n, m; cin >> n >> m; vector<ll> list_1(n, 0), list_2(n, 0); for(ll i = 0; i < n; i++){ cin >> list_1[i]; } ll curr_max = 0; for(ll i = 0; i < n; i++){ cin >> list_2[i]; curr_max = max(curr_max, max(list_2[i], list_1[i])); } ll l = 0, r = m*n*curr_max; while (l + 1 < r){ ll mid = (l + r)/2; ll total = 0; for(ll i = 0; i < n; i++){ if(list_1[i] > list_2[i]){ if(m * list_1[i] < mid){ total += m; total += ceil((double)(mid - m*list_1[i])/(double)list_2[i]); }else{ total += ceil((double)mid/(double)list_1[i]); } }else{ total += ceil((double)mid/(double)list_2[i]); } //cout << total << " " << mid << " " << i << endl; } if(total > m*n){ r = mid; }else{ l = mid; } } cout << l << endl; } bool one_test = true; int main(){ ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); ll t = 1; if(!one_test)cin >> t; while(t--){ solve(); } }
#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...