Submission #1000519

# Submission time Handle Problem Language Result Execution time Memory
1000519 2024-06-17T16:22:12 Z LCJLY Self Study (JOI22_ho_t2) C++14
100 / 100
153 ms 10936 KB
#include <bits/stdc++.h>
using namespace std;
	
#define int long long 
#define ld long double
#define show(x,y) cout << y << " " << #x << endl;
#define show2(x,y,i,j) cout << y << " " << #x << "  " << j << " " << #i << endl;
#define show3(x,y,i,j,p,q) cout << y << " " << #x << "  " << j << " " << #i << "  " << q << " " << #p << endl;
#define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl;
typedef pair<int,int>pii;
typedef array<int,3>pi2;
#define ll __int128

void solve(){	
	int n,m;
	cin >> n >> m;
	pii arr[n];
	for(int x=0;x<n;x++){
		cin >> arr[x].first;
	}	
	
	for(int x=0;x<n;x++){
		cin >> arr[x].second;
		arr[x].first=max(arr[x].first,arr[x].second);
	}
	
	int l=0;
	int r=1e18;
	int mid;
	int best=0;
	while(l<=r){
		mid=(l+r)/2;
		ll counter=0;
		for(int x=0;x<n;x++){
			ll hold=(mid+arr[x].first-1)/arr[x].first;
			if(hold<=m){
				counter+=hold;
			}
			else{
				counter+=m;
				ll hold2=(mid-arr[x].first*m);
				counter+=(hold2+arr[x].second-1)/arr[x].second;
			}
		}
		
		if(counter<=n*m){
			best=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	cout << best;
}	
 
int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin >> t;
	//freopen("in.txt","r",stdin);
	while(t--){
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 4920 KB Output is correct
12 Correct 103 ms 4956 KB Output is correct
13 Correct 106 ms 4956 KB Output is correct
14 Correct 109 ms 4956 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 114 ms 4952 KB Output is correct
17 Correct 114 ms 4952 KB Output is correct
18 Correct 107 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 114 ms 4952 KB Output is correct
3 Correct 114 ms 4952 KB Output is correct
4 Correct 107 ms 4952 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 54 ms 2652 KB Output is correct
14 Correct 37 ms 1884 KB Output is correct
15 Correct 26 ms 1372 KB Output is correct
16 Correct 22 ms 1372 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 2 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 4920 KB Output is correct
12 Correct 103 ms 4956 KB Output is correct
13 Correct 106 ms 4956 KB Output is correct
14 Correct 109 ms 4956 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 54 ms 2652 KB Output is correct
24 Correct 37 ms 1884 KB Output is correct
25 Correct 26 ms 1372 KB Output is correct
26 Correct 22 ms 1372 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 524 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 114 ms 4952 KB Output is correct
36 Correct 114 ms 4952 KB Output is correct
37 Correct 107 ms 4952 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 25 ms 1228 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 0 ms 344 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 344 KB Output is correct
55 Correct 56 ms 2756 KB Output is correct
56 Correct 35 ms 1884 KB Output is correct
57 Correct 36 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 54 ms 2652 KB Output is correct
10 Correct 37 ms 1884 KB Output is correct
11 Correct 26 ms 1372 KB Output is correct
12 Correct 22 ms 1372 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 2 ms 524 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 114 ms 4952 KB Output is correct
22 Correct 114 ms 4952 KB Output is correct
23 Correct 107 ms 4952 KB Output is correct
24 Correct 16 ms 1116 KB Output is correct
25 Correct 79 ms 2532 KB Output is correct
26 Correct 15 ms 856 KB Output is correct
27 Correct 128 ms 5132 KB Output is correct
28 Correct 143 ms 4956 KB Output is correct
29 Correct 119 ms 4952 KB Output is correct
30 Correct 114 ms 4952 KB Output is correct
31 Correct 98 ms 5128 KB Output is correct
32 Correct 111 ms 4952 KB Output is correct
33 Correct 89 ms 4956 KB Output is correct
34 Correct 135 ms 6300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 106 ms 4920 KB Output is correct
12 Correct 103 ms 4956 KB Output is correct
13 Correct 106 ms 4956 KB Output is correct
14 Correct 109 ms 4956 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 54 ms 2652 KB Output is correct
24 Correct 37 ms 1884 KB Output is correct
25 Correct 26 ms 1372 KB Output is correct
26 Correct 22 ms 1372 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 524 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 348 KB Output is correct
42 Correct 3 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 25 ms 1228 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 344 KB Output is correct
51 Correct 56 ms 2756 KB Output is correct
52 Correct 35 ms 1884 KB Output is correct
53 Correct 36 ms 1884 KB Output is correct
54 Correct 16 ms 1116 KB Output is correct
55 Correct 79 ms 2532 KB Output is correct
56 Correct 15 ms 856 KB Output is correct
57 Correct 128 ms 5132 KB Output is correct
58 Correct 143 ms 4956 KB Output is correct
59 Correct 119 ms 4952 KB Output is correct
60 Correct 114 ms 4952 KB Output is correct
61 Correct 98 ms 5128 KB Output is correct
62 Correct 111 ms 4952 KB Output is correct
63 Correct 89 ms 4956 KB Output is correct
64 Correct 135 ms 6300 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 114 ms 4952 KB Output is correct
67 Correct 114 ms 4952 KB Output is correct
68 Correct 107 ms 4952 KB Output is correct
69 Correct 12 ms 1580 KB Output is correct
70 Correct 3 ms 732 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 17 ms 1960 KB Output is correct
73 Correct 4 ms 800 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 153 ms 10832 KB Output is correct
76 Correct 121 ms 10752 KB Output is correct
77 Correct 120 ms 10752 KB Output is correct
78 Correct 124 ms 10836 KB Output is correct
79 Correct 138 ms 10880 KB Output is correct
80 Correct 105 ms 10936 KB Output is correct
81 Correct 88 ms 8836 KB Output is correct
82 Correct 87 ms 8720 KB Output is correct