# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
534355 |
2022-03-08T05:59:58 Z |
PikaQ |
Self Study (JOI22_ho_t2) |
C++17 |
|
426 ms |
7212 KB |
#include<bits/stdc++.h>
#define forn(i,n) for(int i = 0;i < (n);i++)
#define Forn(i,n) for(int i = 1;i <= (n);i++)
#define all(p) p.begin(),p.end()
#define pb push_back
#define F first
#define S second
#define rz resize
#define sz(x) x.size()
#define int long long
#define vi vector<int>
#define pii pair<int,int>
using namespace std;
const int INF = 5000009;
int n,m;
#define double long double
void solve(){
cin >> n >> m;
vi a(n),b(n);
forn(i,n) cin >> a[i];
forn(i,n) cin >> b[i];
forn(i,n){
if(b[i] > a[i]) a[i] = max(b[i],a[i]);
}
int lo = 0,hi = (int)9e18 + (int)10;
while(lo != hi-1){
int mid = (lo+hi)/2;
int res = 0;
forn(i,n){
if(a[i] * m < mid){
res -= ceil(((double)mid - a[i] * m) / b[i]);
continue;
}
int c = ceil((double)mid/a[i]);
res += (m-c);
}
if(res >= 0) lo = mid;
else hi = mid;
}
cout << lo << '\n';
}
signed main(){
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(0);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
332 KB |
Output is correct |
11 |
Correct |
201 ms |
5012 KB |
Output is correct |
12 |
Correct |
236 ms |
5032 KB |
Output is correct |
13 |
Correct |
196 ms |
4940 KB |
Output is correct |
14 |
Correct |
201 ms |
4996 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
207 ms |
5004 KB |
Output is correct |
17 |
Correct |
227 ms |
4940 KB |
Output is correct |
18 |
Correct |
209 ms |
4996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
207 ms |
5004 KB |
Output is correct |
3 |
Correct |
227 ms |
4940 KB |
Output is correct |
4 |
Correct |
209 ms |
4996 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
128 ms |
2664 KB |
Output is correct |
14 |
Correct |
97 ms |
1872 KB |
Output is correct |
15 |
Correct |
72 ms |
1484 KB |
Output is correct |
16 |
Correct |
70 ms |
1228 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
204 KB |
Output is correct |
22 |
Correct |
4 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
332 KB |
Output is correct |
11 |
Correct |
201 ms |
5012 KB |
Output is correct |
12 |
Correct |
236 ms |
5032 KB |
Output is correct |
13 |
Correct |
196 ms |
4940 KB |
Output is correct |
14 |
Correct |
201 ms |
4996 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
128 ms |
2664 KB |
Output is correct |
24 |
Correct |
97 ms |
1872 KB |
Output is correct |
25 |
Correct |
72 ms |
1484 KB |
Output is correct |
26 |
Correct |
70 ms |
1228 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
204 KB |
Output is correct |
32 |
Correct |
4 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
207 ms |
5004 KB |
Output is correct |
36 |
Correct |
227 ms |
4940 KB |
Output is correct |
37 |
Correct |
209 ms |
4996 KB |
Output is correct |
38 |
Correct |
0 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
0 ms |
204 KB |
Output is correct |
45 |
Correct |
9 ms |
392 KB |
Output is correct |
46 |
Correct |
12 ms |
456 KB |
Output is correct |
47 |
Correct |
1 ms |
204 KB |
Output is correct |
48 |
Correct |
50 ms |
1100 KB |
Output is correct |
49 |
Correct |
0 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
7 ms |
332 KB |
Output is correct |
52 |
Correct |
1 ms |
204 KB |
Output is correct |
53 |
Correct |
1 ms |
204 KB |
Output is correct |
54 |
Correct |
1 ms |
204 KB |
Output is correct |
55 |
Correct |
142 ms |
2636 KB |
Output is correct |
56 |
Correct |
73 ms |
1868 KB |
Output is correct |
57 |
Correct |
70 ms |
1868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
128 ms |
2664 KB |
Output is correct |
10 |
Correct |
97 ms |
1872 KB |
Output is correct |
11 |
Correct |
72 ms |
1484 KB |
Output is correct |
12 |
Correct |
70 ms |
1228 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
4 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
207 ms |
5004 KB |
Output is correct |
22 |
Correct |
227 ms |
4940 KB |
Output is correct |
23 |
Correct |
209 ms |
4996 KB |
Output is correct |
24 |
Correct |
52 ms |
972 KB |
Output is correct |
25 |
Correct |
196 ms |
2416 KB |
Output is correct |
26 |
Correct |
41 ms |
716 KB |
Output is correct |
27 |
Correct |
238 ms |
5008 KB |
Output is correct |
28 |
Correct |
296 ms |
4940 KB |
Output is correct |
29 |
Correct |
294 ms |
5012 KB |
Output is correct |
30 |
Correct |
328 ms |
4940 KB |
Output is correct |
31 |
Correct |
244 ms |
4996 KB |
Output is correct |
32 |
Correct |
184 ms |
6168 KB |
Output is correct |
33 |
Correct |
220 ms |
6708 KB |
Output is correct |
34 |
Correct |
220 ms |
6168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
5 ms |
332 KB |
Output is correct |
11 |
Correct |
201 ms |
5012 KB |
Output is correct |
12 |
Correct |
236 ms |
5032 KB |
Output is correct |
13 |
Correct |
196 ms |
4940 KB |
Output is correct |
14 |
Correct |
201 ms |
4996 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
1 ms |
204 KB |
Output is correct |
23 |
Correct |
128 ms |
2664 KB |
Output is correct |
24 |
Correct |
97 ms |
1872 KB |
Output is correct |
25 |
Correct |
72 ms |
1484 KB |
Output is correct |
26 |
Correct |
70 ms |
1228 KB |
Output is correct |
27 |
Correct |
1 ms |
204 KB |
Output is correct |
28 |
Correct |
0 ms |
204 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
204 KB |
Output is correct |
32 |
Correct |
4 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
0 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
204 KB |
Output is correct |
41 |
Correct |
9 ms |
392 KB |
Output is correct |
42 |
Correct |
12 ms |
456 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
50 ms |
1100 KB |
Output is correct |
45 |
Correct |
0 ms |
204 KB |
Output is correct |
46 |
Correct |
1 ms |
204 KB |
Output is correct |
47 |
Correct |
7 ms |
332 KB |
Output is correct |
48 |
Correct |
1 ms |
204 KB |
Output is correct |
49 |
Correct |
1 ms |
204 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Correct |
142 ms |
2636 KB |
Output is correct |
52 |
Correct |
73 ms |
1868 KB |
Output is correct |
53 |
Correct |
70 ms |
1868 KB |
Output is correct |
54 |
Correct |
52 ms |
972 KB |
Output is correct |
55 |
Correct |
196 ms |
2416 KB |
Output is correct |
56 |
Correct |
41 ms |
716 KB |
Output is correct |
57 |
Correct |
238 ms |
5008 KB |
Output is correct |
58 |
Correct |
296 ms |
4940 KB |
Output is correct |
59 |
Correct |
294 ms |
5012 KB |
Output is correct |
60 |
Correct |
328 ms |
4940 KB |
Output is correct |
61 |
Correct |
244 ms |
4996 KB |
Output is correct |
62 |
Correct |
184 ms |
6168 KB |
Output is correct |
63 |
Correct |
220 ms |
6708 KB |
Output is correct |
64 |
Correct |
220 ms |
6168 KB |
Output is correct |
65 |
Correct |
1 ms |
204 KB |
Output is correct |
66 |
Correct |
207 ms |
5004 KB |
Output is correct |
67 |
Correct |
227 ms |
4940 KB |
Output is correct |
68 |
Correct |
209 ms |
4996 KB |
Output is correct |
69 |
Correct |
41 ms |
1344 KB |
Output is correct |
70 |
Correct |
11 ms |
580 KB |
Output is correct |
71 |
Correct |
1 ms |
204 KB |
Output is correct |
72 |
Correct |
54 ms |
1736 KB |
Output is correct |
73 |
Correct |
15 ms |
588 KB |
Output is correct |
74 |
Correct |
2 ms |
332 KB |
Output is correct |
75 |
Correct |
330 ms |
6956 KB |
Output is correct |
76 |
Correct |
342 ms |
7088 KB |
Output is correct |
77 |
Correct |
351 ms |
7212 KB |
Output is correct |
78 |
Correct |
426 ms |
7080 KB |
Output is correct |
79 |
Correct |
420 ms |
7080 KB |
Output is correct |
80 |
Correct |
320 ms |
7092 KB |
Output is correct |
81 |
Correct |
227 ms |
7084 KB |
Output is correct |
82 |
Correct |
187 ms |
7008 KB |
Output is correct |