Submission #978797

# Submission time Handle Problem Language Result Execution time Memory
978797 2024-05-09T17:21:26 Z DobromirAngelov Self Study (JOI22_ho_t2) C++14
100 / 100
208 ms 10400 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

const int MAXN=3e5+5;
const long long INF=1e18+5;

int n,m;
long long a[MAXN];
long long b[MAXN];

bool check(long long val)
{
    long long s=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]*m>=val) s+=(val+a[i]-1)/a[i];
        else s+=m+(val-a[i]*m+b[i]-1)/b[i];
        if(s>1LL*n*m) return 0;
    }
    return 1;
}

int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];

for(int i=1;i<=n;i++) a[i]=max(a[i],b[i]);

long long l=1,r=INF;
while(l<r)
{
    long long mid=(l+r+1)/2;
    if(check(mid)) l=mid;
    else r=mid-1;
}

cout<<l<<endl;

return 0;
}
# 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 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 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 83 ms 9556 KB Output is correct
12 Correct 83 ms 9556 KB Output is correct
13 Correct 67 ms 8020 KB Output is correct
14 Correct 56 ms 8056 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 27 ms 6256 KB Output is correct
17 Correct 80 ms 10400 KB Output is correct
18 Correct 83 ms 9740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 27 ms 6256 KB Output is correct
3 Correct 80 ms 10400 KB Output is correct
4 Correct 83 ms 9740 KB Output is correct
5 Correct 1 ms 2392 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 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 42 ms 7176 KB Output is correct
14 Correct 28 ms 6484 KB Output is correct
15 Correct 24 ms 5980 KB Output is correct
16 Correct 18 ms 5824 KB Output is correct
17 Correct 1 ms 2392 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 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2652 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 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 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 83 ms 9556 KB Output is correct
12 Correct 83 ms 9556 KB Output is correct
13 Correct 67 ms 8020 KB Output is correct
14 Correct 56 ms 8056 KB Output is correct
15 Correct 1 ms 2392 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 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 42 ms 7176 KB Output is correct
24 Correct 28 ms 6484 KB Output is correct
25 Correct 24 ms 5980 KB Output is correct
26 Correct 18 ms 5824 KB Output is correct
27 Correct 1 ms 2392 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 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 27 ms 6256 KB Output is correct
36 Correct 80 ms 10400 KB Output is correct
37 Correct 83 ms 9740 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 0 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 2 ms 2648 KB Output is correct
46 Correct 3 ms 2652 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 15 ms 5724 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 0 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 43 ms 7280 KB Output is correct
56 Correct 27 ms 5976 KB Output is correct
57 Correct 21 ms 5976 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 1 ms 2392 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 2648 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 42 ms 7176 KB Output is correct
10 Correct 28 ms 6484 KB Output is correct
11 Correct 24 ms 5980 KB Output is correct
12 Correct 18 ms 5824 KB Output is correct
13 Correct 1 ms 2392 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 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 27 ms 6256 KB Output is correct
22 Correct 80 ms 10400 KB Output is correct
23 Correct 83 ms 9740 KB Output is correct
24 Correct 26 ms 5720 KB Output is correct
25 Correct 63 ms 7028 KB Output is correct
26 Correct 12 ms 5212 KB Output is correct
27 Correct 79 ms 9720 KB Output is correct
28 Correct 85 ms 9736 KB Output is correct
29 Correct 86 ms 9552 KB Output is correct
30 Correct 109 ms 10032 KB Output is correct
31 Correct 180 ms 9556 KB Output is correct
32 Correct 97 ms 6232 KB Output is correct
33 Correct 207 ms 10356 KB Output is correct
34 Correct 87 ms 6304 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 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 1 ms 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 83 ms 9556 KB Output is correct
12 Correct 83 ms 9556 KB Output is correct
13 Correct 67 ms 8020 KB Output is correct
14 Correct 56 ms 8056 KB Output is correct
15 Correct 1 ms 2392 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 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2648 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 42 ms 7176 KB Output is correct
24 Correct 28 ms 6484 KB Output is correct
25 Correct 24 ms 5980 KB Output is correct
26 Correct 18 ms 5824 KB Output is correct
27 Correct 1 ms 2392 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 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2652 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 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 3 ms 2652 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 15 ms 5724 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 43 ms 7280 KB Output is correct
52 Correct 27 ms 5976 KB Output is correct
53 Correct 21 ms 5976 KB Output is correct
54 Correct 26 ms 5720 KB Output is correct
55 Correct 63 ms 7028 KB Output is correct
56 Correct 12 ms 5212 KB Output is correct
57 Correct 79 ms 9720 KB Output is correct
58 Correct 85 ms 9736 KB Output is correct
59 Correct 86 ms 9552 KB Output is correct
60 Correct 109 ms 10032 KB Output is correct
61 Correct 180 ms 9556 KB Output is correct
62 Correct 97 ms 6232 KB Output is correct
63 Correct 207 ms 10356 KB Output is correct
64 Correct 87 ms 6304 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 27 ms 6256 KB Output is correct
67 Correct 80 ms 10400 KB Output is correct
68 Correct 83 ms 9740 KB Output is correct
69 Correct 19 ms 5212 KB Output is correct
70 Correct 5 ms 2652 KB Output is correct
71 Correct 1 ms 2516 KB Output is correct
72 Correct 28 ms 5336 KB Output is correct
73 Correct 7 ms 2784 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 88 ms 9864 KB Output is correct
76 Correct 98 ms 9516 KB Output is correct
77 Correct 116 ms 9744 KB Output is correct
78 Correct 137 ms 9552 KB Output is correct
79 Correct 189 ms 9840 KB Output is correct
80 Correct 208 ms 9688 KB Output is correct
81 Correct 201 ms 8200 KB Output is correct
82 Correct 195 ms 8016 KB Output is correct