제출 #1295409

#제출 시각아이디문제언어결과실행 시간메모리
1295409ghammazhassanSelf Study (JOI22_ho_t2)C++20
100 / 100
114 ms5136 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> using namespace std; #define int long long #define endl "\n" #define fi first #define se second const int M=1e9+7; const int inf = 1e14; const int LOG=18; const int N=5e1+5; int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r; void solve(){ cin >> n >> m; vector<int>a(n),b(n); for (int i=0;i<n;i++){ cin >> a[i]; } for (int i=0;i<n;i++){ cin >> b[i]; } int l=0; int h=1e18; int mi=(l+h+1)/2; while (l<h){ int op=0; for (int i=0;i<n;i++){ int c=max(a[i],b[i]); int u=(mi+c-1ll)/(c); u=min(u,m); x=mi-u*c; op+=u; if (x>0){ u=(x+b[i]-1ll)/b[i]; op+=u; } if (op>n*m)break; } if (op<=n*m){ l=mi; } else{ h=mi-1; } mi=(l+h+1)/2; } cout << mi << endl; } signed main() { ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE cout << fixed << setprecision(9); srand(time(0)); // int t=1; // cin >> t; for (int _=1;_<=t;_++){ solve(); q++; } }
#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...