답안 #843055

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
843055 2023-09-03T15:33:38 Z _Avocado_ Self Study (JOI22_ho_t2) C++14
100 / 100
304 ms 10936 KB
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int n, m;

int up(int a, int b){
	return (a + (b-1))/b;
}

int min(int a, int b){
	if(a < b) return a;
	return b;
}

const int MAXI = LLONG_MAX;

int check(int x, auto&a, auto&b){
	int sum = 0;
	for(int i = 0; i<n; ++i){
		int days = up(x, a[i]);
		if(sum > MAXI - min(m, days)) return 0;
		sum += min(m, days);
		if(days > m){
			int rest = x - (m*a[i]);
			int extra_days = up(rest, b[i]);
			if(sum > MAXI - extra_days) return 0;
			sum += extra_days;
		}
	}
	
	if(sum <= n*m) return 1;
	return 0;
}
			

int bsearch(auto&a, auto&b){
	int l = -1;
	int r = 2e18;
	
	while(r-l > 1){
		int x = (r+l)/2;
		
		if(check(x, a, b)) l = x;
		else r = x;
	}
	
	return l;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	
	cin>>n>>m;
	
	vector<int>a(n);
	for(auto&u: a) cin>>u;
	vector<int>b(n);
	for(auto&u: b) cin>>u;
	
	for(int i = 0; i<n; ++i){
		a[i] = max(a[i], b[i]);
	}
	
	cout<<bsearch(a, b);
	
	cout<<'\n';
}

Compilation message

Main.cpp:18:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | int check(int x, auto&a, auto&b){
      |                  ^~~~
Main.cpp:18:26: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | int check(int x, auto&a, auto&b){
      |                          ^~~~
Main.cpp:37:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   37 | int bsearch(auto&a, auto&b){
      |             ^~~~
Main.cpp:37:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   37 | int bsearch(auto&a, auto&b){
      |                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 3 ms 580 KB Output is correct
11 Correct 214 ms 10168 KB Output is correct
12 Correct 209 ms 9988 KB Output is correct
13 Correct 216 ms 8460 KB Output is correct
14 Correct 181 ms 6420 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 237 ms 5548 KB Output is correct
17 Correct 242 ms 6928 KB Output is correct
18 Correct 237 ms 6664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 237 ms 5548 KB Output is correct
3 Correct 242 ms 6928 KB Output is correct
4 Correct 237 ms 6664 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 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 109 ms 5688 KB Output is correct
14 Correct 74 ms 3916 KB Output is correct
15 Correct 55 ms 3072 KB Output is correct
16 Correct 44 ms 2316 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 5 ms 348 KB Output is correct
23 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 3 ms 580 KB Output is correct
11 Correct 214 ms 10168 KB Output is correct
12 Correct 209 ms 9988 KB Output is correct
13 Correct 216 ms 8460 KB Output is correct
14 Correct 181 ms 6420 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 109 ms 5688 KB Output is correct
24 Correct 74 ms 3916 KB Output is correct
25 Correct 55 ms 3072 KB Output is correct
26 Correct 44 ms 2316 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 4 ms 344 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 237 ms 5548 KB Output is correct
36 Correct 242 ms 6928 KB Output is correct
37 Correct 237 ms 6664 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 0 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 4 ms 348 KB Output is correct
46 Correct 7 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 40 ms 1480 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 4 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 109 ms 3544 KB Output is correct
56 Correct 74 ms 2544 KB Output is correct
57 Correct 63 ms 2408 KB Output is correct
# 결과 실행 시간 메모리 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 109 ms 5688 KB Output is correct
10 Correct 74 ms 3916 KB Output is correct
11 Correct 55 ms 3072 KB Output is correct
12 Correct 44 ms 2316 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 237 ms 5548 KB Output is correct
22 Correct 242 ms 6928 KB Output is correct
23 Correct 237 ms 6664 KB Output is correct
24 Correct 35 ms 1308 KB Output is correct
25 Correct 104 ms 3168 KB Output is correct
26 Correct 23 ms 872 KB Output is correct
27 Correct 214 ms 6684 KB Output is correct
28 Correct 217 ms 6496 KB Output is correct
29 Correct 220 ms 6884 KB Output is correct
30 Correct 219 ms 6484 KB Output is correct
31 Correct 211 ms 6492 KB Output is correct
32 Correct 233 ms 5420 KB Output is correct
33 Correct 304 ms 6928 KB Output is correct
34 Correct 247 ms 6308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 3 ms 580 KB Output is correct
11 Correct 214 ms 10168 KB Output is correct
12 Correct 209 ms 9988 KB Output is correct
13 Correct 216 ms 8460 KB Output is correct
14 Correct 181 ms 6420 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 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 109 ms 5688 KB Output is correct
24 Correct 74 ms 3916 KB Output is correct
25 Correct 55 ms 3072 KB Output is correct
26 Correct 44 ms 2316 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 4 ms 344 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 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 4 ms 348 KB Output is correct
42 Correct 7 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 40 ms 1480 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 4 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 109 ms 3544 KB Output is correct
52 Correct 74 ms 2544 KB Output is correct
53 Correct 63 ms 2408 KB Output is correct
54 Correct 35 ms 1308 KB Output is correct
55 Correct 104 ms 3168 KB Output is correct
56 Correct 23 ms 872 KB Output is correct
57 Correct 214 ms 6684 KB Output is correct
58 Correct 217 ms 6496 KB Output is correct
59 Correct 220 ms 6884 KB Output is correct
60 Correct 219 ms 6484 KB Output is correct
61 Correct 211 ms 6492 KB Output is correct
62 Correct 233 ms 5420 KB Output is correct
63 Correct 304 ms 6928 KB Output is correct
64 Correct 247 ms 6308 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 237 ms 5548 KB Output is correct
67 Correct 242 ms 6928 KB Output is correct
68 Correct 237 ms 6664 KB Output is correct
69 Correct 25 ms 1368 KB Output is correct
70 Correct 7 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 33 ms 1988 KB Output is correct
73 Correct 8 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 218 ms 10936 KB Output is correct
76 Correct 221 ms 10836 KB Output is correct
77 Correct 223 ms 10932 KB Output is correct
78 Correct 229 ms 10936 KB Output is correct
79 Correct 237 ms 10860 KB Output is correct
80 Correct 228 ms 10728 KB Output is correct
81 Correct 293 ms 8952 KB Output is correct
82 Correct 269 ms 8952 KB Output is correct