Submission #724798

#TimeUsernameProblemLanguageResultExecution timeMemory
724798CookieSelf Study (JOI22_ho_t2)C++14
100 / 100
255 ms11468 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; ifstream fin("WINTER.inp"); ofstream fout("WINTER.out"); #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> const ld PI = 3.14159265359; const ll mod = 1e9 + 7; const int mxn = 3e5 + 5, mxv = 1e6; ll n, m; ll a[mxn + 1], b[mxn + 1]; bool ck(ll mid){ ll need = 0; forr(i, 0, n){ ll have = max(a[i], b[i]) * m; ll val = mid / max(a[i], b[i]); if(mid % max(a[i], b[i]))val++; need += min(val, m); if(mid > have){ need += ceil((ld)(mid - have) / (ld)(b[i])); } if(need > n * m)return(false); } return(need <= n * m); } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; forr(i, 0, n){ cin >> a[i]; } forr(i, 0, n)cin >> b[i]; ll l = 1, r= 1e18, ans = 0; while(l <= r){ ll mid = (l + r) >> 1; if(ck(mid)){ ans = mid; l = mid + 1; }else{ r = mid - 1; } } cout << ans; 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...