Submission #923033

# Submission time Handle Problem Language Result Execution time Memory
923033 2024-02-06T13:06:35 Z ting39 Self Study (JOI22_ho_t2) C++17
100 / 100
503 ms 10932 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
vector<int> a,b;
int dv(int x,int y){
	if(x<=0||y*(x/y)==x) return x/y;
	else return x/y+1;
}
bool check(int x){
	int all=0;
	for(int i=0;i<n;i++){
		int emp=0,ext=0;
		all+=min(dv(x,a[i]),m);
		all+=max(dv(x-m*a[i],b[i]),0LL);
		if(n*m<all) return 0;
	}
	return 1;
}
signed main(){
	cin>>n>>m;
	a.resize(n);
	b.resize(n);
	for(int &i:a) cin>>i;
	for(int i=0;i<n;i++){
		cin>>b[i];
		a[i]=max(a[i],b[i]);
	}
	int l=0,r=1e18+100,mid;
	while(r-l>1){
		mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l<<endl;
}

Compilation message

Main.cpp: In function 'bool check(long long int)':
Main.cpp:13:7: warning: unused variable 'emp' [-Wunused-variable]
   13 |   int emp=0,ext=0;
      |       ^~~
Main.cpp:13:13: warning: unused variable 'ext' [-Wunused-variable]
   13 |   int emp=0,ext=0;
      |             ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 238 ms 5112 KB Output is correct
12 Correct 240 ms 5112 KB Output is correct
13 Correct 186 ms 5120 KB Output is correct
14 Correct 177 ms 4956 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 70 ms 5120 KB Output is correct
17 Correct 252 ms 4956 KB Output is correct
18 Correct 234 ms 5112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 70 ms 5120 KB Output is correct
3 Correct 252 ms 4956 KB Output is correct
4 Correct 234 ms 5112 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 121 ms 2788 KB Output is correct
14 Correct 81 ms 1884 KB Output is correct
15 Correct 60 ms 1592 KB Output is correct
16 Correct 50 ms 1368 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 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 2 ms 348 KB Output is correct
23 Correct 5 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 238 ms 5112 KB Output is correct
12 Correct 240 ms 5112 KB Output is correct
13 Correct 186 ms 5120 KB Output is correct
14 Correct 177 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 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 121 ms 2788 KB Output is correct
24 Correct 81 ms 1884 KB Output is correct
25 Correct 60 ms 1592 KB Output is correct
26 Correct 50 ms 1368 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 5 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 70 ms 5120 KB Output is correct
36 Correct 252 ms 4956 KB Output is correct
37 Correct 234 ms 5112 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 344 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 5 ms 348 KB Output is correct
46 Correct 8 ms 568 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 43 ms 1252 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 5 ms 344 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 344 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 127 ms 2752 KB Output is correct
56 Correct 70 ms 1992 KB Output is correct
57 Correct 63 ms 1880 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 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 121 ms 2788 KB Output is correct
10 Correct 81 ms 1884 KB Output is correct
11 Correct 60 ms 1592 KB Output is correct
12 Correct 50 ms 1368 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 70 ms 5120 KB Output is correct
22 Correct 252 ms 4956 KB Output is correct
23 Correct 234 ms 5112 KB Output is correct
24 Correct 64 ms 1112 KB Output is correct
25 Correct 156 ms 2396 KB Output is correct
26 Correct 29 ms 860 KB Output is correct
27 Correct 258 ms 4952 KB Output is correct
28 Correct 250 ms 5116 KB Output is correct
29 Correct 260 ms 5116 KB Output is correct
30 Correct 290 ms 4952 KB Output is correct
31 Correct 463 ms 5112 KB Output is correct
32 Correct 219 ms 5884 KB Output is correct
33 Correct 445 ms 8704 KB Output is correct
34 Correct 215 ms 6292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 238 ms 5112 KB Output is correct
12 Correct 240 ms 5112 KB Output is correct
13 Correct 186 ms 5120 KB Output is correct
14 Correct 177 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 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 121 ms 2788 KB Output is correct
24 Correct 81 ms 1884 KB Output is correct
25 Correct 60 ms 1592 KB Output is correct
26 Correct 50 ms 1368 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 5 ms 348 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 344 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 5 ms 348 KB Output is correct
42 Correct 8 ms 568 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 43 ms 1252 KB Output is correct
45 Correct 0 ms 344 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 5 ms 344 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 344 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 127 ms 2752 KB Output is correct
52 Correct 70 ms 1992 KB Output is correct
53 Correct 63 ms 1880 KB Output is correct
54 Correct 64 ms 1112 KB Output is correct
55 Correct 156 ms 2396 KB Output is correct
56 Correct 29 ms 860 KB Output is correct
57 Correct 258 ms 4952 KB Output is correct
58 Correct 250 ms 5116 KB Output is correct
59 Correct 260 ms 5116 KB Output is correct
60 Correct 290 ms 4952 KB Output is correct
61 Correct 463 ms 5112 KB Output is correct
62 Correct 219 ms 5884 KB Output is correct
63 Correct 445 ms 8704 KB Output is correct
64 Correct 215 ms 6292 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 70 ms 5120 KB Output is correct
67 Correct 252 ms 4956 KB Output is correct
68 Correct 234 ms 5112 KB Output is correct
69 Correct 48 ms 1372 KB Output is correct
70 Correct 15 ms 604 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 71 ms 1932 KB Output is correct
73 Correct 14 ms 856 KB Output is correct
74 Correct 2 ms 460 KB Output is correct
75 Correct 273 ms 10740 KB Output is correct
76 Correct 297 ms 10868 KB Output is correct
77 Correct 329 ms 10932 KB Output is correct
78 Correct 386 ms 10924 KB Output is correct
79 Correct 476 ms 10876 KB Output is correct
80 Correct 503 ms 10868 KB Output is correct
81 Correct 401 ms 8944 KB Output is correct
82 Correct 452 ms 8940 KB Output is correct