| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1341644 | iamhereforfun | Self Study (JOI22_ho_t2) | C++20 | 1 ms | 344 KiB |
// Starcraft 2 enjoyer //
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
using namespace std;
#define LSOne(X) ((X) & -(X))
const int N = 3e5 + 5;
const int K = 1e2 + 5;
const int M = 2e5 + 5;
const int LG = 20;
const long long INF = 1e18 + 5;
const int C = 26;
const int B = 1000;
const int MOD = 998244353;
long long n, m, a[N], b[N];
long long l, r, ans;
inline void solve()
{
cin >> n >> m;
for (int x = 0; x < n; x++)
{
cin >> a[x];
}
for (int x = 0; x < n; x++)
{
cin >> b[x];
a[x] = max(a[x], b[x]);
}
l = 0, r = INF, ans = 0;
while (l <= r)
{
long long md = (l + r) / 2, cnt = 0;
for (int x = 0; x < n; x++)
{
if (cnt > 1LL * n * m)
{
break;
}
long long i = md;
if (i > a[x] * m)
{
i -= a[x] * m;
cnt += m;
cnt += (i - 1) / b[x] + 1;
}
else
{
cnt += (md - 1) / a[x] + 1;
}
}
if (cnt > 1LL * n * m)
{
r = md - 1;
}
else
{
l = md + 1;
ans = md;
}
}
cout << ans << "\n";
}
signed main()
{
freopen("CP.INP", "r", stdin);
freopen("CP.OUT", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
for (int x = 1; x <= t; x++)
{
solve();
}
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... | ||||
