# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
803554 | 2023-08-03T04:51:15 Z | vjudge1 | Self Study (JOI22_ho_t2) | C++17 | 325 ms | 13784 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define fi first #define se second #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll d[N] = {} , a[N] = {}, dp[N] = {}, b[N] , c[N]; void solve(){ ll q , i , j , m ,n, z , l , r , k , x , y , mn = 1e18 , mx = -1; cin>>n>>k; ld s , f; for(i = 1; i <= n; i++) cin>>a[i]; for(i = 1; i <= n; i++) cin>>b[i]; l = 1; r = 1e18; while(l != r){ m = (l + r + 1) / 2; s = f = 0; for(i = 1; i <= n; i++){ c[i] = max(a[i] , b[i]) * k; if(c[i] > m) x = (c[i] - m) / max(a[i] , b[i]) , f += x; if(c[i] < m) x = (((m - c[i]) / b[i]) + ((m - c[i]) % b[i] != 0)) , s += x; } if(s <= f) l = m; else r = m - 1; } cout<<l<<"\n"; } int main(){ /* TL; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | 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 | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 261 ms | 7340 KB | Output is correct |
12 | Correct | 265 ms | 7236 KB | Output is correct |
13 | Correct | 217 ms | 7284 KB | Output is correct |
14 | Correct | 289 ms | 7340 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 219 ms | 8516 KB | Output is correct |
17 | Correct | 277 ms | 13784 KB | Output is correct |
18 | Correct | 315 ms | 13140 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 219 ms | 8516 KB | Output is correct |
3 | Correct | 277 ms | 13784 KB | Output is correct |
4 | Correct | 315 ms | 13140 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 | 212 KB | Output is correct |
13 | Correct | 132 ms | 3832 KB | Output is correct |
14 | Correct | 97 ms | 2564 KB | Output is correct |
15 | Correct | 67 ms | 2060 KB | Output is correct |
16 | Correct | 54 ms | 1680 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 | 1 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 4 ms | 340 KB | Output is correct |
23 | Correct | 7 ms | 444 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 | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 261 ms | 7340 KB | Output is correct |
12 | Correct | 265 ms | 7236 KB | Output is correct |
13 | Correct | 217 ms | 7284 KB | Output is correct |
14 | Correct | 289 ms | 7340 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 | 212 KB | Output is correct |
23 | Correct | 132 ms | 3832 KB | Output is correct |
24 | Correct | 97 ms | 2564 KB | Output is correct |
25 | Correct | 67 ms | 2060 KB | Output is correct |
26 | Correct | 54 ms | 1680 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 | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 4 ms | 340 KB | Output is correct |
33 | Correct | 7 ms | 444 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 219 ms | 8516 KB | Output is correct |
36 | Correct | 277 ms | 13784 KB | Output is correct |
37 | Correct | 315 ms | 13140 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 1 ms | 212 KB | Output is correct |
40 | Correct | 1 ms | 308 KB | Output is correct |
41 | Correct | 1 ms | 212 KB | Output is correct |
42 | Correct | 1 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 0 ms | 212 KB | Output is correct |
45 | Correct | 5 ms | 468 KB | Output is correct |
46 | Correct | 8 ms | 664 KB | Output is correct |
47 | Correct | 1 ms | 340 KB | Output is correct |
48 | Correct | 49 ms | 2460 KB | Output is correct |
49 | Correct | 1 ms | 212 KB | Output is correct |
50 | Correct | 1 ms | 312 KB | Output is correct |
51 | Correct | 5 ms | 468 KB | Output is correct |
52 | Correct | 1 ms | 212 KB | Output is correct |
53 | Correct | 1 ms | 212 KB | Output is correct |
54 | Correct | 1 ms | 308 KB | Output is correct |
55 | Correct | 130 ms | 6652 KB | Output is correct |
56 | Correct | 75 ms | 3836 KB | Output is correct |
57 | Correct | 88 ms | 3908 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 | 212 KB | Output is correct |
9 | Correct | 132 ms | 3832 KB | Output is correct |
10 | Correct | 97 ms | 2564 KB | Output is correct |
11 | Correct | 67 ms | 2060 KB | Output is correct |
12 | Correct | 54 ms | 1680 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 | 1 ms | 212 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 4 ms | 340 KB | Output is correct |
19 | Correct | 7 ms | 444 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 219 ms | 8516 KB | Output is correct |
22 | Correct | 277 ms | 13784 KB | Output is correct |
23 | Correct | 315 ms | 13140 KB | Output is correct |
24 | Correct | 48 ms | 2232 KB | Output is correct |
25 | Correct | 133 ms | 5984 KB | Output is correct |
26 | Correct | 29 ms | 1612 KB | Output is correct |
27 | Correct | 311 ms | 13068 KB | Output is correct |
28 | Correct | 264 ms | 13160 KB | Output is correct |
29 | Correct | 267 ms | 13148 KB | Output is correct |
30 | Correct | 305 ms | 13040 KB | Output is correct |
31 | Correct | 322 ms | 13092 KB | Output is correct |
32 | Correct | 220 ms | 8524 KB | Output is correct |
33 | Correct | 291 ms | 13736 KB | Output is correct |
34 | Correct | 225 ms | 8524 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 | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 4 ms | 340 KB | Output is correct |
11 | Correct | 261 ms | 7340 KB | Output is correct |
12 | Correct | 265 ms | 7236 KB | Output is correct |
13 | Correct | 217 ms | 7284 KB | Output is correct |
14 | Correct | 289 ms | 7340 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 | 212 KB | Output is correct |
23 | Correct | 132 ms | 3832 KB | Output is correct |
24 | Correct | 97 ms | 2564 KB | Output is correct |
25 | Correct | 67 ms | 2060 KB | Output is correct |
26 | Correct | 54 ms | 1680 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 | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 4 ms | 340 KB | Output is correct |
33 | Correct | 7 ms | 444 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 1 ms | 308 KB | Output is correct |
37 | Correct | 1 ms | 212 KB | Output is correct |
38 | Correct | 1 ms | 212 KB | Output is correct |
39 | Correct | 1 ms | 212 KB | Output is correct |
40 | Correct | 0 ms | 212 KB | Output is correct |
41 | Correct | 5 ms | 468 KB | Output is correct |
42 | Correct | 8 ms | 664 KB | Output is correct |
43 | Correct | 1 ms | 340 KB | Output is correct |
44 | Correct | 49 ms | 2460 KB | Output is correct |
45 | Correct | 1 ms | 212 KB | Output is correct |
46 | Correct | 1 ms | 312 KB | Output is correct |
47 | Correct | 5 ms | 468 KB | Output is correct |
48 | Correct | 1 ms | 212 KB | Output is correct |
49 | Correct | 1 ms | 212 KB | Output is correct |
50 | Correct | 1 ms | 308 KB | Output is correct |
51 | Correct | 130 ms | 6652 KB | Output is correct |
52 | Correct | 75 ms | 3836 KB | Output is correct |
53 | Correct | 88 ms | 3908 KB | Output is correct |
54 | Correct | 48 ms | 2232 KB | Output is correct |
55 | Correct | 133 ms | 5984 KB | Output is correct |
56 | Correct | 29 ms | 1612 KB | Output is correct |
57 | Correct | 311 ms | 13068 KB | Output is correct |
58 | Correct | 264 ms | 13160 KB | Output is correct |
59 | Correct | 267 ms | 13148 KB | Output is correct |
60 | Correct | 305 ms | 13040 KB | Output is correct |
61 | Correct | 322 ms | 13092 KB | Output is correct |
62 | Correct | 220 ms | 8524 KB | Output is correct |
63 | Correct | 291 ms | 13736 KB | Output is correct |
64 | Correct | 225 ms | 8524 KB | Output is correct |
65 | Correct | 1 ms | 212 KB | Output is correct |
66 | Correct | 219 ms | 8516 KB | Output is correct |
67 | Correct | 277 ms | 13784 KB | Output is correct |
68 | Correct | 315 ms | 13140 KB | Output is correct |
69 | Correct | 33 ms | 1596 KB | Output is correct |
70 | Correct | 11 ms | 596 KB | Output is correct |
71 | Correct | 1 ms | 212 KB | Output is correct |
72 | Correct | 45 ms | 2152 KB | Output is correct |
73 | Correct | 11 ms | 724 KB | Output is correct |
74 | Correct | 1 ms | 340 KB | Output is correct |
75 | Correct | 263 ms | 13152 KB | Output is correct |
76 | Correct | 272 ms | 13152 KB | Output is correct |
77 | Correct | 274 ms | 13152 KB | Output is correct |
78 | Correct | 289 ms | 13156 KB | Output is correct |
79 | Correct | 320 ms | 13108 KB | Output is correct |
80 | Correct | 325 ms | 13152 KB | Output is correct |
81 | Correct | 216 ms | 11164 KB | Output is correct |
82 | Correct | 220 ms | 11212 KB | Output is correct |