Submission #638784

#TimeUsernameProblemLanguageResultExecution timeMemory
638784penguin133Self Study (JOI22_ho_t2)C++14
100 / 100
237 ms6148 KiB
#include <bits/stdc++.h> using namespace std; #define int __int128 #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define fi first #define se second long long n,k; long long A[300005], B[300005], P[200005]; void solve(){ cin >> n >> k; for(int i=1;i<=n;i++)cin >> A[i]; for(int i=1;i<=n;i++)cin >> B[i], A[i] = max(A[i], B[i]); int s = 0, e = 8e18, ans = s; while(s <= e){ int m = s + (e-s)/2; int cnt = 0; for(int i=1;i<=n;i++){ if(A[i]*k < m)cnt -= ((m - A[i] * k + B[i] - 1)/ B[i]); else { int x = (m + A[i] - 1) / A[i]; cnt += k - x; } } if(cnt >= 0)ans = m, s = m + 1; else e = m - 1; } cout << (long long)ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

Main.cpp:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main(){
      | ^~~~
#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...