# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
593621 |
2022-07-11T12:48:14 Z |
vovik |
Self Study (JOI22_ho_t2) |
C++17 |
|
183 ms |
4788 KB |
#include <bits/stdc++.h>
namespace IO {
const int DPAIRSIZ = 1 << 10;
char BB[DPAIRSIZ], *SS = BB, *TT = BB;
inline char getcha() {
return SS == TT && (TT = (SS = BB) + fread(BB, 1, DPAIRSIZ, stdin), SS == TT) ? EOF : *SS++;
}
template<typename T = int>
inline T read() {
T x = 0;
int fu = 1;
char c = getcha();
while (c > 57 || c < 48) {
if (c == 45) fu = -1;
c = getcha();
}
while (c <= 57 && c >= 48) {
x = x * 10 + c - 48;
c = getcha();
}
x *= fu;
return x;
}
template<typename T>
inline void read(T &x) {
x = 0;
int fu = 1;
char c = getcha();
while (c > 57 || c < 48) {
if (c == 45) fu = -1;
c = getcha();
}
while (c <= 57 && c >= 48) {
x = x * 10 + c - 48;
c = getcha();
}
x *= fu;
}
template<typename T>
inline void read(T *bg, T *ed) { while (bg != ed) read(*bg++); }
inline void read(char &ch) {
ch = getcha();
while (ch <= 32) ch = getcha();
}
inline void read(char *s) {
char ch = getcha();
while (ch <= 32) ch = getcha();
while (ch > 32) *s++ = ch, ch = getcha();
*s = '\0';
}
inline void read(std::string &s) {
char ch = getcha();
while (ch <= 32) ch = getcha();
while (ch > 32) s.push_back(ch), ch = getcha();
}
inline void sread(char *s) {
char ch = getcha();
while (ch < 32) ch = getcha();
while (ch >= 32) *s++ = ch, ch = getcha();
*s = '\0';
}
inline void pread(char *&s) {
char ch = getcha();
while (ch <= 32) ch = getcha();
while (ch > 32) *s++ = ch, ch = getcha();
*s = '\0';
}
inline void spread(char *&s) {
char ch = getcha();
while (ch < 32) ch = getcha();
while (ch >= 32) *s++ = ch, ch = getcha();
*s = '\0';
}
template<typename T, typename ...Args>
inline void read(T &x, Args &...args) {
read(x);
read(args...);
}
char out[DPAIRSIZ], *Out = out;
#define flush() fwrite(out, 1, Out - out, stdout)
inline void putcha(char x) {
*Out++ = x;
if (Out - out >= (DPAIRSIZ)) flush(), Out = out;
}
template<typename T>
inline void fprint(T x) {
if (x < 0) putcha(45), x = -x;
if (x > 9) fprint(x / 10);
putcha(x % 10 + 48);
}
inline void print() { putcha(10); }
template<typename T>
inline void print(T x) {
fprint(x);
putcha(10);
}
inline void print(char *ch) {
while (*ch != '\0') putcha(*(ch++));
putcha(10);
}
inline void put(char *ch) { while (*ch != '\0') putcha(*(ch++)); }
inline void print(const char *ch) {
while (*ch != '\0') putcha(*(ch++));
putcha(10);
}
inline void put(const char *ch) { while (*ch != '\0') putcha(*(ch++)); }
template<typename T, typename ...Args>
inline void print(T x, Args ...args) {
fprint(x);
putcha(32);
print(args...);
}
template<typename ...Args>
inline void print(const char *ch, Args ...args) {
while (*ch != '\0') putcha(*(ch++));
putcha(32);
print(args...);
}
template<typename ...Args>
inline void print(char *ch, Args ...args) {
while (*ch != '\0') putcha(*(ch++));
putcha(32);
print(args...);
}
template<typename T, typename ...Args>
inline void printl(T x, Args ...args) {
fprint(x);
putcha(10);
printl(args...);
}
template<typename ...Args>
inline void printl(const char *ch, Args ...args) {
while (*ch != '\0') putcha(*(ch++));
putcha(10);
printl(args...);
}
template<typename ...Args>
inline void printl(char *ch, Args ...args) {
while (*ch != '\0') putcha(*(ch++));
putcha(10);
printl(args...);
}
template<typename T>
inline void sprint(T x) {
fprint(x);
putcha(32);
}
template<typename T, typename ...Args>
inline void sprint(T x, Args ...args) {
fprint(x);
putcha(32);
sprint(args...);
}
template<typename T>
inline void sprint(T *bg, T *ed) { while (bg != ed) sprint(*bg++); }
template<typename T>
inline void print(T *bg, T *ed) {
while (bg != ed) sprint(*bg++);
putcha(10);
}
template<typename T>
inline void printl(T *bg, T *ed) { while (bg != ed) print(*bg++); }
class AutoFlush {
public:
~AutoFlush() { flush(); }
} __AutoFlush;
} // namespace IO
using namespace IO;
#define vc vector
#define nd node*
#define pnd pair<nd, nd>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vc<pll> vpll;
typedef vc<vll> vvll;
typedef vc<vpll> vvpll;
template<const ll MOD>
struct mod_mul : std::multiplies<const ll> {
ll operator()(const ll a, const ll b) {
return (a * b) % MOD;
}
};
template<typename T>
inline void sort(T &a) {
sort(a.begin(), a.end());
}
template<typename T>
inline void unique(T &a) {
a.resize(unique(a.begin(), a.end()) - a.begin());
}
template<typename T>
inline void reverse(T &a) {
reverse(a.begin(), a.end());
}
const ll INF = 9023372036854775808ll;
const ll MOD = 1000000007ll;
int main() {
int n = read();
int m = read();
vc<int> a(n), b(n);
for (auto &i: a) read(i);
for (auto &i: b) read(i);
int sm = 0;
for (int i = 0; i < n; ++i) sm += a[i] < b[i];
auto check = [&](ll x) {
ll need = 0;
for (int i = 0; i < n; ++i) {
need += (x + max(a[i], b[i]) - 1) / (ll)max(a[i], b[i]);
if (need > (ll)n * m) return false;
}
return need <= (ll)n * m;
};
ll l = 0, r = 2e18 + 1;
while (r - l > 1) {
ll mid = (l + r) / 2;
if (check(mid)) {
l = mid;
} else {
r = mid;
}
}
cout << l << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
51 ms |
2644 KB |
Output is correct |
12 |
Correct |
51 ms |
2644 KB |
Output is correct |
13 |
Correct |
42 ms |
2644 KB |
Output is correct |
14 |
Correct |
44 ms |
2644 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
8 ms |
2668 KB |
Output is correct |
17 |
Correct |
50 ms |
2644 KB |
Output is correct |
18 |
Correct |
47 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
8 ms |
2668 KB |
Output is correct |
3 |
Correct |
50 ms |
2644 KB |
Output is correct |
4 |
Correct |
47 ms |
2648 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 |
308 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
300 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
28 ms |
3508 KB |
Output is correct |
14 |
Correct |
19 ms |
3004 KB |
Output is correct |
15 |
Correct |
15 ms |
2296 KB |
Output is correct |
16 |
Correct |
12 ms |
1920 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
304 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
51 ms |
2644 KB |
Output is correct |
12 |
Correct |
51 ms |
2644 KB |
Output is correct |
13 |
Correct |
42 ms |
2644 KB |
Output is correct |
14 |
Correct |
44 ms |
2644 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
308 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
300 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
28 ms |
3508 KB |
Output is correct |
24 |
Correct |
19 ms |
3004 KB |
Output is correct |
25 |
Correct |
15 ms |
2296 KB |
Output is correct |
26 |
Correct |
12 ms |
1920 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
304 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
8 ms |
2668 KB |
Output is correct |
36 |
Correct |
50 ms |
2644 KB |
Output is correct |
37 |
Correct |
47 ms |
2648 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
212 KB |
Output is correct |
40 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
41 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
308 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
300 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 |
28 ms |
3508 KB |
Output is correct |
10 |
Correct |
19 ms |
3004 KB |
Output is correct |
11 |
Correct |
15 ms |
2296 KB |
Output is correct |
12 |
Correct |
12 ms |
1920 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
304 KB |
Output is correct |
15 |
Correct |
0 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 |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
8 ms |
2668 KB |
Output is correct |
22 |
Correct |
50 ms |
2644 KB |
Output is correct |
23 |
Correct |
47 ms |
2648 KB |
Output is correct |
24 |
Correct |
24 ms |
1560 KB |
Output is correct |
25 |
Correct |
52 ms |
3400 KB |
Output is correct |
26 |
Correct |
8 ms |
1148 KB |
Output is correct |
27 |
Correct |
52 ms |
4648 KB |
Output is correct |
28 |
Correct |
59 ms |
4688 KB |
Output is correct |
29 |
Correct |
58 ms |
4788 KB |
Output is correct |
30 |
Correct |
80 ms |
4624 KB |
Output is correct |
31 |
Correct |
160 ms |
4692 KB |
Output is correct |
32 |
Correct |
103 ms |
3796 KB |
Output is correct |
33 |
Correct |
183 ms |
4680 KB |
Output is correct |
34 |
Correct |
92 ms |
3812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
51 ms |
2644 KB |
Output is correct |
12 |
Correct |
51 ms |
2644 KB |
Output is correct |
13 |
Correct |
42 ms |
2644 KB |
Output is correct |
14 |
Correct |
44 ms |
2644 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
308 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
300 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
28 ms |
3508 KB |
Output is correct |
24 |
Correct |
19 ms |
3004 KB |
Output is correct |
25 |
Correct |
15 ms |
2296 KB |
Output is correct |
26 |
Correct |
12 ms |
1920 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
304 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
2 ms |
340 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
1 ms |
212 KB |
Output is correct |
36 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
37 |
Halted |
0 ms |
0 KB |
- |