# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991560 | rsinventor | Self Study (JOI22_ho_t2) | C++17 | 107 ms | 11604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector <pii> vpii;
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define endl "\n"
ll n, m;
ll adds(ll mid, vll& a, vll& b) {
ll sum = 0;
for(int i = 0; i < a.size(); i++) {
if(a[i]>b[i]) {
ll class_cnt = 1 + ((mid - 1) / a[i]);
if (class_cnt > m) {
sum += 1 + ((mid - a[i] * m - 1) / b[i]) + m;
} else {
sum += class_cnt;
}
} else {
sum += 1 + ((mid-1)/b[i]);
}
}
return sum;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
vll a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
vll b(n);
for(int i = 0; i < n; i++) {
cin >> b[i];
}
ll l = 0;
ll r = 50000000000000;
while(l<r) {
ll mid = l + (r - l)/2;
if(adds(mid, a, b)<=n*m) {
l = mid+1;
} else {
r = mid;
}
}
cout << l-1 << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |