#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
int n;
long long m;
long long a[maxn];
long long b[maxn];
long long round_up(long long x, long long y)
{
if (x % y == 0)
{
return x / y;
}
return x / y + 1;
}
bool check(long long min_score)
{
unsigned long long free_lections = 0;
for (int i = 1; i <= n; ++i)
{
if (b[i] >= a[i])
{
long long curr = round_up(min_score, b[i]);
free_lections += (m - curr);
}
else
{
long long curr_lections = round_up(min_score, a[i]);
if (curr_lections <= m)
{
free_lections += (m - curr_lections);
}
else
{
long long add_lections = round_up(min_score - m * a[i], b[i]);
free_lections -= add_lections;
}
}
}
return free_lections >= 0;
}
void fastIO()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main()
{
fastIO();
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= n; ++i)
{
cin >> b[i];
}
long long l = 0;
long long r = 1e18;
while (l <= r)
{
long long mid = (l + r) / 2;
if (check(mid) == false)
{
r = mid - 1;
}
else
{
l = mid + 1;
}
}
cout << r << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |