Submission #534414

# Submission time Handle Problem Language Result Execution time Memory
534414 2022-03-08T06:51:12 Z Wither Self Study (JOI22_ho_t2) C++14
100 / 100
267 ms 8996 KB
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define Fors(i,a,b,s) for(int i=a;i<=b;i+=s)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define INF (ll)(9e18)
#define endl '\n'
#define int long long int
using namespace std;
using pii=pair<int,int>;

int UB=1000000000000000010;
int LB=0;


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N,M;
	cin>>N>>M;
	int tc=N*M;
	
	int A[N],B[N];
	for (int i=0;i<N;i++){
		cin>>A[i];
	}
	for (int i=0;i<N;i++){
		cin>>B[i];
	}
	
	
	 
	
	while (LB!=UB){
		int ndc=0;
		int ddc=0;
		int m=(LB+UB)/2;
		for (int i=0;i<N;i++){
			if (A[i]>B[i]){
				int c=m/A[i]+1;
				if (c<=M){
					ddc+=M-c;
				}
				else{
					ndc+=(m-A[i]*M)/B[i]+1;
				}
			}
			else{
				int c=m/B[i]+1;
				if (c<=M){
					ddc+=M-c;
				}
				else{
					ndc+=(m-B[i]*M)/B[i]+1;
				}
			}
			if (ndc>tc){
				break;
			}
		}
		if (ndc>ddc){
			UB=m;
		}
		else{
			LB=m+1;
		}	
	}
	cout<<UB<<endl;
	
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 110 ms 7316 KB Output is correct
12 Correct 114 ms 7372 KB Output is correct
13 Correct 137 ms 7172 KB Output is correct
14 Correct 81 ms 7160 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 35 ms 6156 KB Output is correct
17 Correct 178 ms 7268 KB Output is correct
18 Correct 107 ms 7272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 35 ms 6156 KB Output is correct
3 Correct 178 ms 7268 KB Output is correct
4 Correct 107 ms 7272 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 56 ms 4888 KB Output is correct
14 Correct 37 ms 3752 KB Output is correct
15 Correct 27 ms 2832 KB Output is correct
16 Correct 26 ms 2364 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 400 KB Output is correct
23 Correct 4 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 110 ms 7316 KB Output is correct
12 Correct 114 ms 7372 KB Output is correct
13 Correct 137 ms 7172 KB Output is correct
14 Correct 81 ms 7160 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 56 ms 4888 KB Output is correct
24 Correct 37 ms 3752 KB Output is correct
25 Correct 27 ms 2832 KB Output is correct
26 Correct 26 ms 2364 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 312 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 400 KB Output is correct
33 Correct 4 ms 452 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 35 ms 6156 KB Output is correct
36 Correct 178 ms 7268 KB Output is correct
37 Correct 107 ms 7272 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 3 ms 484 KB Output is correct
46 Correct 4 ms 584 KB Output is correct
47 Correct 1 ms 320 KB Output is correct
48 Correct 24 ms 1976 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 3 ms 460 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 61 ms 5436 KB Output is correct
56 Correct 47 ms 3000 KB Output is correct
57 Correct 30 ms 3124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 56 ms 4888 KB Output is correct
10 Correct 37 ms 3752 KB Output is correct
11 Correct 27 ms 2832 KB Output is correct
12 Correct 26 ms 2364 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 0 ms 312 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 4 ms 452 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 35 ms 6156 KB Output is correct
22 Correct 178 ms 7268 KB Output is correct
23 Correct 107 ms 7272 KB Output is correct
24 Correct 36 ms 1860 KB Output is correct
25 Correct 90 ms 4932 KB Output is correct
26 Correct 17 ms 1356 KB Output is correct
27 Correct 106 ms 8624 KB Output is correct
28 Correct 130 ms 8540 KB Output is correct
29 Correct 122 ms 8504 KB Output is correct
30 Correct 152 ms 8744 KB Output is correct
31 Correct 233 ms 8996 KB Output is correct
32 Correct 168 ms 4984 KB Output is correct
33 Correct 264 ms 7276 KB Output is correct
34 Correct 204 ms 5012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 110 ms 7316 KB Output is correct
12 Correct 114 ms 7372 KB Output is correct
13 Correct 137 ms 7172 KB Output is correct
14 Correct 81 ms 7160 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 56 ms 4888 KB Output is correct
24 Correct 37 ms 3752 KB Output is correct
25 Correct 27 ms 2832 KB Output is correct
26 Correct 26 ms 2364 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 312 KB Output is correct
30 Correct 0 ms 312 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 400 KB Output is correct
33 Correct 4 ms 452 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 3 ms 484 KB Output is correct
42 Correct 4 ms 584 KB Output is correct
43 Correct 1 ms 320 KB Output is correct
44 Correct 24 ms 1976 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 3 ms 460 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 61 ms 5436 KB Output is correct
52 Correct 47 ms 3000 KB Output is correct
53 Correct 30 ms 3124 KB Output is correct
54 Correct 36 ms 1860 KB Output is correct
55 Correct 90 ms 4932 KB Output is correct
56 Correct 17 ms 1356 KB Output is correct
57 Correct 106 ms 8624 KB Output is correct
58 Correct 130 ms 8540 KB Output is correct
59 Correct 122 ms 8504 KB Output is correct
60 Correct 152 ms 8744 KB Output is correct
61 Correct 233 ms 8996 KB Output is correct
62 Correct 168 ms 4984 KB Output is correct
63 Correct 264 ms 7276 KB Output is correct
64 Correct 204 ms 5012 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 35 ms 6156 KB Output is correct
67 Correct 178 ms 7268 KB Output is correct
68 Correct 107 ms 7272 KB Output is correct
69 Correct 24 ms 812 KB Output is correct
70 Correct 6 ms 332 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 34 ms 972 KB Output is correct
73 Correct 9 ms 460 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 138 ms 7312 KB Output is correct
76 Correct 138 ms 7276 KB Output is correct
77 Correct 159 ms 7272 KB Output is correct
78 Correct 208 ms 7272 KB Output is correct
79 Correct 260 ms 7316 KB Output is correct
80 Correct 267 ms 7268 KB Output is correct
81 Correct 252 ms 6800 KB Output is correct
82 Correct 246 ms 6724 KB Output is correct