# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
538665 |
2022-03-17T12:06:45 Z |
faruk |
Self Study (JOI22_ho_t2) |
C++17 |
|
373 ms |
5012 KB |
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ll long long
#define ld long double
using namespace std;
vector<ll> a;
vector<ll> b;
int n; ll m;
bool binary(ll x) {
ll possible = 0;
for (int i = 0; i < n ; i++) {
ll val = a[i] * m;
if (val < x)
continue;
ll diff = val - x;
possible += diff / a[i];
}
for (int i = 0; i < n; i++) {
ll val = a[i] * m;
if (val >= x)
continue;
ll dif = x - val;
ll needed = dif / b[i];
if (dif % b[i])
needed++;
possible -= needed;
}
return possible < 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
a.resize(n);
b.resize(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 0; i < n; i++)
{
cin >> b[i];
a[i] = max(a[i], b[i]);
}
ll l = 0, r = 5e18;
while (l < r) {
ll mid = (l + r) / 2;
if (binary(mid))
r = mid;
else
l = mid + 1;
}
cout << l - 1<< "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
183 ms |
4948 KB |
Output is correct |
12 |
Correct |
190 ms |
5012 KB |
Output is correct |
13 |
Correct |
192 ms |
5008 KB |
Output is correct |
14 |
Incorrect |
373 ms |
5012 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
94 ms |
2644 KB |
Output is correct |
10 |
Correct |
64 ms |
1876 KB |
Output is correct |
11 |
Correct |
50 ms |
1492 KB |
Output is correct |
12 |
Correct |
39 ms |
1264 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
6 ms |
392 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
183 ms |
4948 KB |
Output is correct |
12 |
Correct |
190 ms |
5012 KB |
Output is correct |
13 |
Correct |
192 ms |
5008 KB |
Output is correct |
14 |
Incorrect |
373 ms |
5012 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
94 ms |
2644 KB |
Output is correct |
10 |
Correct |
64 ms |
1876 KB |
Output is correct |
11 |
Correct |
50 ms |
1492 KB |
Output is correct |
12 |
Correct |
39 ms |
1264 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
6 ms |
392 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
183 ms |
4948 KB |
Output is correct |
12 |
Correct |
190 ms |
5012 KB |
Output is correct |
13 |
Correct |
192 ms |
5008 KB |
Output is correct |
14 |
Incorrect |
373 ms |
5012 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |