/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const ll maxn = 300010;
ll n, m;
ll a[maxn], b[maxn], in[maxn], out[maxn], cp[maxn];
void solve()
{
cin >> n >> m;
bool diff = false;
for (ll i = 1; i <= n; i ++)
cin >> a[i];
for (ll i = 1; i <= n; i ++)
{
cin >> b[i];
if (b[i] != a[i])
diff = true;
}
if (m == 1)
{
ll mx = 1e9;
for (int i = 1; i <= n; i ++)
mx = min(mx, max(a[i], b[i]));
cout << mx << endl;
}
else
if (!diff)
{
ll sum = 0;
for (int i = 1; i <= n; i ++)
sum = sum + m * a[i];
ll lf = 0, rf = sum / n + 1;
while(lf <= rf)
{
ll mf = (lf + rf) / 2;
ll nec = 0;
for (int i = 1; i <= n; i ++)
{
nec = nec + mf / a[i];
if (mf % a[i] != 0)
nec ++;
}
if (nec <= n * m)
lf = mf + 1;
else
rf = mf - 1;
}
cout << rf << endl;
}
}
int main()
{
solve();
return 0;
}
# |
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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
210 ms |
4960 KB |
Output is correct |
12 |
Correct |
214 ms |
4892 KB |
Output is correct |
13 |
Correct |
156 ms |
4960 KB |
Output is correct |
14 |
Correct |
148 ms |
5064 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
81 ms |
5176 KB |
Output is correct |
17 |
Correct |
259 ms |
4880 KB |
Output is correct |
18 |
Correct |
208 ms |
4884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
81 ms |
5176 KB |
Output is correct |
3 |
Correct |
259 ms |
4880 KB |
Output is correct |
4 |
Correct |
208 ms |
4884 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 |
304 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
130 ms |
5544 KB |
Output is correct |
14 |
Correct |
88 ms |
3704 KB |
Output is correct |
15 |
Correct |
63 ms |
2912 KB |
Output is correct |
16 |
Correct |
52 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
7 ms |
488 KB |
Output is correct |
# |
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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
210 ms |
4960 KB |
Output is correct |
12 |
Correct |
214 ms |
4892 KB |
Output is correct |
13 |
Correct |
156 ms |
4960 KB |
Output is correct |
14 |
Correct |
148 ms |
5064 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
130 ms |
5544 KB |
Output is correct |
24 |
Correct |
88 ms |
3704 KB |
Output is correct |
25 |
Correct |
63 ms |
2912 KB |
Output is correct |
26 |
Correct |
52 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
7 ms |
488 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
81 ms |
5176 KB |
Output is correct |
36 |
Correct |
259 ms |
4880 KB |
Output is correct |
37 |
Correct |
208 ms |
4884 KB |
Output is correct |
38 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
39 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
304 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
130 ms |
5544 KB |
Output is correct |
10 |
Correct |
88 ms |
3704 KB |
Output is correct |
11 |
Correct |
63 ms |
2912 KB |
Output is correct |
12 |
Correct |
52 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
7 ms |
488 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
81 ms |
5176 KB |
Output is correct |
22 |
Correct |
259 ms |
4880 KB |
Output is correct |
23 |
Correct |
208 ms |
4884 KB |
Output is correct |
24 |
Incorrect |
44 ms |
1824 KB |
Output isn't correct |
25 |
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 |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
340 KB |
Output is correct |
11 |
Correct |
210 ms |
4960 KB |
Output is correct |
12 |
Correct |
214 ms |
4892 KB |
Output is correct |
13 |
Correct |
156 ms |
4960 KB |
Output is correct |
14 |
Correct |
148 ms |
5064 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
304 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
130 ms |
5544 KB |
Output is correct |
24 |
Correct |
88 ms |
3704 KB |
Output is correct |
25 |
Correct |
63 ms |
2912 KB |
Output is correct |
26 |
Correct |
52 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Correct |
1 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
2 ms |
340 KB |
Output is correct |
33 |
Correct |
7 ms |
488 KB |
Output is correct |
34 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
35 |
Halted |
0 ms |
0 KB |
- |