Submission #941833

#TimeUsernameProblemLanguageResultExecution timeMemory
941833ErJSelf Study (JOI22_ho_t2)C++17
100 / 100
333 ms11384 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define vvi vector<vector<ll>> #define vs vector<string> #define vc vector<char> #define vb vector<bool> #define vp vector<pair<ll, ll>> #define pp pair<ll, ll> #define qi queue<ll> #define qp queue<pp> #define pqi priority_queue<ll> #define pqp priority_queue<pp> #define mi map<ll, ll> #define mpi map<pp, ll> #define mip map<ll, pp> #define mpp map<pp, pp> #define mb map<ll, bool> #define si set<ll> #define sp set<pp> #define mod 1000000007 #define rep(a, b) for(int a = 0; a < (b); a++) #define rep2(a, b) for(int a = 1; a < (b); a++) #define inf 100000000000000 vi A, B; ll n, m; bool check(ll x) { ll ans = 0; rep(i, n) { ll c = max(A[i], B[i]); if (x < m * c) { ans += (x + c - 1) / c; } else { ans += m; ll y = x - c * m; ans += (y + B[i] - 1) / B[i]; } if (ans > n * m) { break; } } if (ans <= n * m) { return true; } else { return false; } } int main() { cin >> n >> m; A.resize(n); B.resize(n); rep(i, n) { cin >> A[i]; } rep(i, n) { cin >> B[i]; } ll MAX = 1000000000000000009; ll MIN = 0; while (MIN + 1 < MAX) { ll s = (MIN + MAX) / 2; bool bs = check(s); if (bs) { MIN = s; } else { MAX = s; } } cout << MIN << endl; }
#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...