# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
573041 |
2022-06-05T16:39:02 Z |
groshi |
Self Study (JOI22_ho_t2) |
C++17 |
|
245 ms |
11480 KB |
#include<iostream>
using namespace std;
#define int long long
long long a[1000000],b[1000000];
long long n,m;
bool ok(long long ile)
{
//cout<<"check "<<ile<<"\n";
long long biore=0;
for(int i=1;i<=n;i++)
{
if(a[i]>b[i])
{
long long ile_kursow_ja=ile/a[i];
if(ile%a[i]!=0)
ile_kursow_ja++;
if(ile_kursow_ja<=m)
{
biore+=ile_kursow_ja;
if(biore>n*m)
return 0;
continue;
}
else{
biore+=m;
long long reszta=ile-m*a[i];
if(reszta<0)
continue;
long long dod=reszta/b[i];
if(reszta%b[i]!=0)
dod++;
biore+=dod;
if(biore>n*m)
return 0;
continue;
}
}
long long ile_kursow=ile/b[i];
if(ile%b[i]!=0)
ile_kursow++;
biore+=ile_kursow;
if(biore>n*m)
return 0;
//cout<<ile_kursow_ja<<" "<<wolne<<"\n";
}
if(biore<=n*m)
return 1;
else return 0;
}
int32_t main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
cin>>b[i];
long long pocz=0,kon=3*1e18+1,sre,ostd=0;
//cout<<pocz<<" "<<kon<<"\n";
while(pocz<kon)
{
sre=(pocz+kon)/2;
//cout<<sre<<": "<<ok(sre)<<"\n";
if(ok(sre))
{
ostd=sre;
pocz=sre+1;
}
else kon=sre;
}
cout<<ostd;
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 |
1 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 |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
104 ms |
5016 KB |
Output is correct |
12 |
Correct |
107 ms |
5076 KB |
Output is correct |
13 |
Correct |
84 ms |
4924 KB |
Output is correct |
14 |
Correct |
76 ms |
4984 KB |
Output is correct |
15 |
Correct |
1 ms |
416 KB |
Output is correct |
16 |
Correct |
30 ms |
6132 KB |
Output is correct |
17 |
Correct |
109 ms |
11408 KB |
Output is correct |
18 |
Correct |
99 ms |
10812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
416 KB |
Output is correct |
2 |
Correct |
30 ms |
6132 KB |
Output is correct |
3 |
Correct |
109 ms |
11408 KB |
Output is correct |
4 |
Correct |
99 ms |
10812 KB |
Output is correct |
5 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
224 KB |
Output is correct |
13 |
Correct |
48 ms |
2668 KB |
Output is correct |
14 |
Correct |
31 ms |
1876 KB |
Output is correct |
15 |
Correct |
23 ms |
1460 KB |
Output is correct |
16 |
Correct |
20 ms |
1276 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
212 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 |
3 ms |
468 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 |
1 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 |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
104 ms |
5016 KB |
Output is correct |
12 |
Correct |
107 ms |
5076 KB |
Output is correct |
13 |
Correct |
84 ms |
4924 KB |
Output is correct |
14 |
Correct |
76 ms |
4984 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 |
0 ms |
212 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 |
0 ms |
224 KB |
Output is correct |
23 |
Correct |
48 ms |
2668 KB |
Output is correct |
24 |
Correct |
31 ms |
1876 KB |
Output is correct |
25 |
Correct |
23 ms |
1460 KB |
Output is correct |
26 |
Correct |
20 ms |
1276 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 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 |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
416 KB |
Output is correct |
35 |
Correct |
30 ms |
6132 KB |
Output is correct |
36 |
Correct |
109 ms |
11408 KB |
Output is correct |
37 |
Correct |
99 ms |
10812 KB |
Output is correct |
38 |
Correct |
1 ms |
308 KB |
Output is correct |
39 |
Correct |
0 ms |
340 KB |
Output is correct |
40 |
Correct |
1 ms |
340 KB |
Output is correct |
41 |
Correct |
0 ms |
340 KB |
Output is correct |
42 |
Correct |
0 ms |
340 KB |
Output is correct |
43 |
Correct |
0 ms |
212 KB |
Output is correct |
44 |
Correct |
0 ms |
340 KB |
Output is correct |
45 |
Correct |
3 ms |
468 KB |
Output is correct |
46 |
Correct |
4 ms |
588 KB |
Output is correct |
47 |
Correct |
1 ms |
340 KB |
Output is correct |
48 |
Correct |
22 ms |
2132 KB |
Output is correct |
49 |
Correct |
0 ms |
340 KB |
Output is correct |
50 |
Correct |
1 ms |
340 KB |
Output is correct |
51 |
Correct |
2 ms |
472 KB |
Output is correct |
52 |
Correct |
0 ms |
340 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
0 ms |
328 KB |
Output is correct |
55 |
Correct |
58 ms |
5456 KB |
Output is correct |
56 |
Correct |
31 ms |
3156 KB |
Output is correct |
57 |
Correct |
26 ms |
3156 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
224 KB |
Output is correct |
9 |
Correct |
48 ms |
2668 KB |
Output is correct |
10 |
Correct |
31 ms |
1876 KB |
Output is correct |
11 |
Correct |
23 ms |
1460 KB |
Output is correct |
12 |
Correct |
20 ms |
1276 KB |
Output is correct |
13 |
Correct |
1 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
416 KB |
Output is correct |
21 |
Correct |
30 ms |
6132 KB |
Output is correct |
22 |
Correct |
109 ms |
11408 KB |
Output is correct |
23 |
Correct |
99 ms |
10812 KB |
Output is correct |
24 |
Correct |
31 ms |
1972 KB |
Output is correct |
25 |
Correct |
71 ms |
4944 KB |
Output is correct |
26 |
Correct |
12 ms |
1364 KB |
Output is correct |
27 |
Correct |
97 ms |
10832 KB |
Output is correct |
28 |
Correct |
101 ms |
10828 KB |
Output is correct |
29 |
Correct |
101 ms |
10776 KB |
Output is correct |
30 |
Correct |
131 ms |
10936 KB |
Output is correct |
31 |
Correct |
209 ms |
10820 KB |
Output is correct |
32 |
Correct |
114 ms |
6188 KB |
Output is correct |
33 |
Correct |
245 ms |
11480 KB |
Output is correct |
34 |
Correct |
120 ms |
6192 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 |
1 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 |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
104 ms |
5016 KB |
Output is correct |
12 |
Correct |
107 ms |
5076 KB |
Output is correct |
13 |
Correct |
84 ms |
4924 KB |
Output is correct |
14 |
Correct |
76 ms |
4984 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 |
0 ms |
212 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 |
0 ms |
224 KB |
Output is correct |
23 |
Correct |
48 ms |
2668 KB |
Output is correct |
24 |
Correct |
31 ms |
1876 KB |
Output is correct |
25 |
Correct |
23 ms |
1460 KB |
Output is correct |
26 |
Correct |
20 ms |
1276 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
0 ms |
212 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 |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
308 KB |
Output is correct |
35 |
Correct |
0 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
0 ms |
340 KB |
Output is correct |
38 |
Correct |
0 ms |
340 KB |
Output is correct |
39 |
Correct |
0 ms |
212 KB |
Output is correct |
40 |
Correct |
0 ms |
340 KB |
Output is correct |
41 |
Correct |
3 ms |
468 KB |
Output is correct |
42 |
Correct |
4 ms |
588 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
22 ms |
2132 KB |
Output is correct |
45 |
Correct |
0 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
2 ms |
472 KB |
Output is correct |
48 |
Correct |
0 ms |
340 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
0 ms |
328 KB |
Output is correct |
51 |
Correct |
58 ms |
5456 KB |
Output is correct |
52 |
Correct |
31 ms |
3156 KB |
Output is correct |
53 |
Correct |
26 ms |
3156 KB |
Output is correct |
54 |
Correct |
31 ms |
1972 KB |
Output is correct |
55 |
Correct |
71 ms |
4944 KB |
Output is correct |
56 |
Correct |
12 ms |
1364 KB |
Output is correct |
57 |
Correct |
97 ms |
10832 KB |
Output is correct |
58 |
Correct |
101 ms |
10828 KB |
Output is correct |
59 |
Correct |
101 ms |
10776 KB |
Output is correct |
60 |
Correct |
131 ms |
10936 KB |
Output is correct |
61 |
Correct |
209 ms |
10820 KB |
Output is correct |
62 |
Correct |
114 ms |
6188 KB |
Output is correct |
63 |
Correct |
245 ms |
11480 KB |
Output is correct |
64 |
Correct |
120 ms |
6192 KB |
Output is correct |
65 |
Correct |
1 ms |
416 KB |
Output is correct |
66 |
Correct |
30 ms |
6132 KB |
Output is correct |
67 |
Correct |
109 ms |
11408 KB |
Output is correct |
68 |
Correct |
99 ms |
10812 KB |
Output is correct |
69 |
Correct |
23 ms |
1516 KB |
Output is correct |
70 |
Correct |
6 ms |
572 KB |
Output is correct |
71 |
Correct |
0 ms |
328 KB |
Output is correct |
72 |
Correct |
33 ms |
1736 KB |
Output is correct |
73 |
Correct |
7 ms |
596 KB |
Output is correct |
74 |
Correct |
1 ms |
340 KB |
Output is correct |
75 |
Correct |
125 ms |
10824 KB |
Output is correct |
76 |
Correct |
131 ms |
10700 KB |
Output is correct |
77 |
Correct |
140 ms |
10828 KB |
Output is correct |
78 |
Correct |
168 ms |
10824 KB |
Output is correct |
79 |
Correct |
222 ms |
10924 KB |
Output is correct |
80 |
Correct |
235 ms |
10804 KB |
Output is correct |
81 |
Correct |
223 ms |
8788 KB |
Output is correct |
82 |
Correct |
217 ms |
8908 KB |
Output is correct |