# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018604 |
2024-07-10T07:21:30 Z |
vicvic |
Self Study (JOI22_ho_t2) |
C++11 |
|
278 ms |
11348 KB |
#include <iostream>
#include <fstream>
#include <climits>
#define int long long
using namespace std;
const int nmax=3e5+5;
int n, m, a[nmax], b[nmax];
bool check (int val)
{
int days=n*m;
for (int i=1;i<=n;i++)
{
int filled=0;
if (a[i]>b[i])
{
int nr_act=min (days, m);
if (!nr_act)
{
return 0;
}
if (LLONG_MAX/nr_act>a[i] && nr_act*a[i]<val)
{
days-=nr_act;
filled=nr_act*a[i];
}
else
{
days-=val/a[i]+(val%a[i]!=0);
continue;
}
}
int nr_act=days;
if (!nr_act)
{
return 0;
}
if (LLONG_MAX/nr_act>b[i] && nr_act*b[i]<val-filled)
{
return 0;
}
days-=(val-filled)/b[i]+((val-filled)%b[i]!=0);
if (days<0)
{
return 0;
}
}
return 1;
}
int32_t main()
{
cin >> n >> m;
for (int i=1;i<=n;i++)
{
cin >> a[i];
}
for (int i=1;i<=n;i++)
{
cin >> b[i];
}
int st=0, dr=1e18, poz=0;
while (st<=dr)
{
int mij = (st+dr) >> 1;
if (check (mij))
{
st=mij+1;
poz=mij;
}
else dr=mij-1;
}
cout << poz;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
4 ms |
2396 KB |
Output is correct |
11 |
Correct |
271 ms |
7996 KB |
Output is correct |
12 |
Correct |
224 ms |
8016 KB |
Output is correct |
13 |
Correct |
157 ms |
6992 KB |
Output is correct |
14 |
Correct |
140 ms |
6992 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
66 ms |
5732 KB |
Output is correct |
17 |
Correct |
213 ms |
8672 KB |
Output is correct |
18 |
Correct |
185 ms |
7956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
66 ms |
5732 KB |
Output is correct |
3 |
Correct |
213 ms |
8672 KB |
Output is correct |
4 |
Correct |
185 ms |
7956 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2496 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
149 ms |
6292 KB |
Output is correct |
14 |
Correct |
64 ms |
5968 KB |
Output is correct |
15 |
Correct |
45 ms |
5488 KB |
Output is correct |
16 |
Correct |
40 ms |
5460 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2496 KB |
Output is correct |
21 |
Correct |
1 ms |
2652 KB |
Output is correct |
22 |
Correct |
2 ms |
2396 KB |
Output is correct |
23 |
Correct |
4 ms |
2508 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
4 ms |
2396 KB |
Output is correct |
11 |
Correct |
271 ms |
7996 KB |
Output is correct |
12 |
Correct |
224 ms |
8016 KB |
Output is correct |
13 |
Correct |
157 ms |
6992 KB |
Output is correct |
14 |
Correct |
140 ms |
6992 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2392 KB |
Output is correct |
19 |
Correct |
1 ms |
2496 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2392 KB |
Output is correct |
23 |
Correct |
149 ms |
6292 KB |
Output is correct |
24 |
Correct |
64 ms |
5968 KB |
Output is correct |
25 |
Correct |
45 ms |
5488 KB |
Output is correct |
26 |
Correct |
40 ms |
5460 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2496 KB |
Output is correct |
31 |
Correct |
1 ms |
2652 KB |
Output is correct |
32 |
Correct |
2 ms |
2396 KB |
Output is correct |
33 |
Correct |
4 ms |
2508 KB |
Output is correct |
34 |
Correct |
1 ms |
2392 KB |
Output is correct |
35 |
Correct |
66 ms |
5732 KB |
Output is correct |
36 |
Correct |
213 ms |
8672 KB |
Output is correct |
37 |
Correct |
185 ms |
7956 KB |
Output is correct |
38 |
Correct |
1 ms |
2396 KB |
Output is correct |
39 |
Correct |
1 ms |
2396 KB |
Output is correct |
40 |
Correct |
0 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2488 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
0 ms |
2396 KB |
Output is correct |
44 |
Correct |
0 ms |
2396 KB |
Output is correct |
45 |
Correct |
7 ms |
2396 KB |
Output is correct |
46 |
Correct |
8 ms |
2652 KB |
Output is correct |
47 |
Correct |
1 ms |
2396 KB |
Output is correct |
48 |
Correct |
34 ms |
5252 KB |
Output is correct |
49 |
Correct |
1 ms |
2396 KB |
Output is correct |
50 |
Correct |
1 ms |
2396 KB |
Output is correct |
51 |
Correct |
4 ms |
2396 KB |
Output is correct |
52 |
Correct |
1 ms |
2396 KB |
Output is correct |
53 |
Correct |
1 ms |
2396 KB |
Output is correct |
54 |
Correct |
1 ms |
2392 KB |
Output is correct |
55 |
Correct |
102 ms |
6484 KB |
Output is correct |
56 |
Correct |
53 ms |
5312 KB |
Output is correct |
57 |
Correct |
49 ms |
5468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2496 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
149 ms |
6292 KB |
Output is correct |
10 |
Correct |
64 ms |
5968 KB |
Output is correct |
11 |
Correct |
45 ms |
5488 KB |
Output is correct |
12 |
Correct |
40 ms |
5460 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2496 KB |
Output is correct |
17 |
Correct |
1 ms |
2652 KB |
Output is correct |
18 |
Correct |
2 ms |
2396 KB |
Output is correct |
19 |
Correct |
4 ms |
2508 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
66 ms |
5732 KB |
Output is correct |
22 |
Correct |
213 ms |
8672 KB |
Output is correct |
23 |
Correct |
185 ms |
7956 KB |
Output is correct |
24 |
Correct |
37 ms |
5376 KB |
Output is correct |
25 |
Correct |
115 ms |
7252 KB |
Output is correct |
26 |
Correct |
21 ms |
5324 KB |
Output is correct |
27 |
Correct |
194 ms |
10908 KB |
Output is correct |
28 |
Correct |
195 ms |
10836 KB |
Output is correct |
29 |
Correct |
206 ms |
10880 KB |
Output is correct |
30 |
Correct |
195 ms |
10832 KB |
Output is correct |
31 |
Correct |
220 ms |
10832 KB |
Output is correct |
32 |
Correct |
99 ms |
6180 KB |
Output is correct |
33 |
Correct |
240 ms |
11348 KB |
Output is correct |
34 |
Correct |
92 ms |
6048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
4 ms |
2396 KB |
Output is correct |
11 |
Correct |
271 ms |
7996 KB |
Output is correct |
12 |
Correct |
224 ms |
8016 KB |
Output is correct |
13 |
Correct |
157 ms |
6992 KB |
Output is correct |
14 |
Correct |
140 ms |
6992 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2392 KB |
Output is correct |
19 |
Correct |
1 ms |
2496 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2392 KB |
Output is correct |
23 |
Correct |
149 ms |
6292 KB |
Output is correct |
24 |
Correct |
64 ms |
5968 KB |
Output is correct |
25 |
Correct |
45 ms |
5488 KB |
Output is correct |
26 |
Correct |
40 ms |
5460 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2496 KB |
Output is correct |
31 |
Correct |
1 ms |
2652 KB |
Output is correct |
32 |
Correct |
2 ms |
2396 KB |
Output is correct |
33 |
Correct |
4 ms |
2508 KB |
Output is correct |
34 |
Correct |
1 ms |
2396 KB |
Output is correct |
35 |
Correct |
1 ms |
2396 KB |
Output is correct |
36 |
Correct |
0 ms |
2396 KB |
Output is correct |
37 |
Correct |
1 ms |
2488 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
0 ms |
2396 KB |
Output is correct |
41 |
Correct |
7 ms |
2396 KB |
Output is correct |
42 |
Correct |
8 ms |
2652 KB |
Output is correct |
43 |
Correct |
1 ms |
2396 KB |
Output is correct |
44 |
Correct |
34 ms |
5252 KB |
Output is correct |
45 |
Correct |
1 ms |
2396 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
4 ms |
2396 KB |
Output is correct |
48 |
Correct |
1 ms |
2396 KB |
Output is correct |
49 |
Correct |
1 ms |
2396 KB |
Output is correct |
50 |
Correct |
1 ms |
2392 KB |
Output is correct |
51 |
Correct |
102 ms |
6484 KB |
Output is correct |
52 |
Correct |
53 ms |
5312 KB |
Output is correct |
53 |
Correct |
49 ms |
5468 KB |
Output is correct |
54 |
Correct |
37 ms |
5376 KB |
Output is correct |
55 |
Correct |
115 ms |
7252 KB |
Output is correct |
56 |
Correct |
21 ms |
5324 KB |
Output is correct |
57 |
Correct |
194 ms |
10908 KB |
Output is correct |
58 |
Correct |
195 ms |
10836 KB |
Output is correct |
59 |
Correct |
206 ms |
10880 KB |
Output is correct |
60 |
Correct |
195 ms |
10832 KB |
Output is correct |
61 |
Correct |
220 ms |
10832 KB |
Output is correct |
62 |
Correct |
99 ms |
6180 KB |
Output is correct |
63 |
Correct |
240 ms |
11348 KB |
Output is correct |
64 |
Correct |
92 ms |
6048 KB |
Output is correct |
65 |
Correct |
1 ms |
2392 KB |
Output is correct |
66 |
Correct |
66 ms |
5732 KB |
Output is correct |
67 |
Correct |
213 ms |
8672 KB |
Output is correct |
68 |
Correct |
185 ms |
7956 KB |
Output is correct |
69 |
Correct |
32 ms |
5208 KB |
Output is correct |
70 |
Correct |
7 ms |
2500 KB |
Output is correct |
71 |
Correct |
1 ms |
2392 KB |
Output is correct |
72 |
Correct |
35 ms |
5536 KB |
Output is correct |
73 |
Correct |
8 ms |
2652 KB |
Output is correct |
74 |
Correct |
1 ms |
2396 KB |
Output is correct |
75 |
Correct |
199 ms |
10900 KB |
Output is correct |
76 |
Correct |
205 ms |
10788 KB |
Output is correct |
77 |
Correct |
215 ms |
10780 KB |
Output is correct |
78 |
Correct |
278 ms |
10792 KB |
Output is correct |
79 |
Correct |
245 ms |
10836 KB |
Output is correct |
80 |
Correct |
244 ms |
10836 KB |
Output is correct |
81 |
Correct |
181 ms |
8784 KB |
Output is correct |
82 |
Correct |
186 ms |
8740 KB |
Output is correct |