Submission #842831

# Submission time Handle Problem Language Result Execution time Memory
842831 2023-09-03T11:59:02 Z _Avocado_ Self Study (JOI22_ho_t2) C++14
0 / 100
420 ms 5200 KB
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int n, m;

int up(int a, int b){
	int ret = a/b;
	if(a%b) ++ret;
	return ret;
}

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

int bsearch(auto&a, auto&b){
	int l = -1;
	int r = 1e18+18;
	
	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:13:18: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   13 | int check(int x, auto&a, auto&b){
      |                  ^~~~
Main.cpp:13:26: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   13 | int check(int x, auto&a, auto&b){
      |                          ^~~~
Main.cpp:30:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   30 | int bsearch(auto&a, auto&b){
      |             ^~~~
Main.cpp:30:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   30 | int bsearch(auto&a, auto&b){
      |                     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 202 ms 4944 KB Output is correct
12 Correct 200 ms 5136 KB Output is correct
13 Correct 206 ms 4952 KB Output is correct
14 Incorrect 420 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 106 ms 2792 KB Output is correct
10 Correct 70 ms 2016 KB Output is correct
11 Correct 51 ms 1624 KB Output is correct
12 Correct 43 ms 1572 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 9 ms 600 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 202 ms 4944 KB Output is correct
12 Correct 200 ms 5136 KB Output is correct
13 Correct 206 ms 4952 KB Output is correct
14 Incorrect 420 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 106 ms 2792 KB Output is correct
10 Correct 70 ms 2016 KB Output is correct
11 Correct 51 ms 1624 KB Output is correct
12 Correct 43 ms 1572 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 9 ms 600 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 600 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 202 ms 4944 KB Output is correct
12 Correct 200 ms 5136 KB Output is correct
13 Correct 206 ms 4952 KB Output is correct
14 Incorrect 420 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -