#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
lli n, m;
bool check(lli x, vll &v1, vll &v2)
{
lli tot = 0;
frange(i, n)
{
lli e1 = v1[i];
lli e2 = v2[i];
if (e1 > e2)
{
lli tmp = x;
lli v = (tmp + e1 - 1) / e1;
tmp -= e1 * min(m, v);
tot += min(m, v);
if (tmp > 0)
{
v = (tmp + e2 - 1) / e2;
tot += v;
}
}
else
{
tot += (x + e2 - 1) / e2;
}
}
return tot <= n * m;
}
int main()
{
sclld(n);
sclld(m);
vll vec1(n);
vll vec2(n);
frange(i, n)
{
sclld(vec1[i]);
}
frange(i, n)
{
lli a;
sclld(a);
vec2[i] = a;
}
// mi = *min_element(all(vec));
lli hi = 4e18;
lli lo = 0;
while (hi != lo)
{
lli mid = (hi + lo + 1) / 2;
if (check(mid, vec1, vec2))
{
lo = mid;
}
else
{
hi = mid - 1;
}
}
printf("%lld", lo);
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | #define sclld(t) scanf("%lld", &t)
| ~~~~~^~~~~~~~~~~~
Main.cpp:67:5: note: in expansion of macro 'sclld'
67 | sclld(n);
| ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | #define sclld(t) scanf("%lld", &t)
| ~~~~~^~~~~~~~~~~~
Main.cpp:68:5: note: in expansion of macro 'sclld'
68 | sclld(m);
| ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | #define sclld(t) scanf("%lld", &t)
| ~~~~~^~~~~~~~~~~~
Main.cpp:73:9: note: in expansion of macro 'sclld'
73 | sclld(vec1[i]);
| ^~~~~
Main.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | #define sclld(t) scanf("%lld", &t)
| ~~~~~^~~~~~~~~~~~
Main.cpp:78:9: note: in expansion of macro 'sclld'
78 | sclld(a);
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
420 KB |
Output is correct |
11 |
Correct |
210 ms |
5272 KB |
Output is correct |
12 |
Correct |
214 ms |
5088 KB |
Output is correct |
13 |
Correct |
167 ms |
5208 KB |
Output is correct |
14 |
Incorrect |
485 ms |
5204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
87 ms |
2996 KB |
Output is correct |
10 |
Correct |
58 ms |
2124 KB |
Output is correct |
11 |
Correct |
44 ms |
1740 KB |
Output is correct |
12 |
Correct |
37 ms |
1476 KB |
Output is correct |
13 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
420 KB |
Output is correct |
11 |
Correct |
210 ms |
5272 KB |
Output is correct |
12 |
Correct |
214 ms |
5088 KB |
Output is correct |
13 |
Correct |
167 ms |
5208 KB |
Output is correct |
14 |
Incorrect |
485 ms |
5204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
87 ms |
2996 KB |
Output is correct |
10 |
Correct |
58 ms |
2124 KB |
Output is correct |
11 |
Correct |
44 ms |
1740 KB |
Output is correct |
12 |
Correct |
37 ms |
1476 KB |
Output is correct |
13 |
Correct |
1 ms |
212 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 |
1 ms |
212 KB |
Output is correct |
18 |
Incorrect |
5 ms |
340 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
4 ms |
420 KB |
Output is correct |
11 |
Correct |
210 ms |
5272 KB |
Output is correct |
12 |
Correct |
214 ms |
5088 KB |
Output is correct |
13 |
Correct |
167 ms |
5208 KB |
Output is correct |
14 |
Incorrect |
485 ms |
5204 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |