Submission #526380

# Submission time Handle Problem Language Result Execution time Memory
526380 2022-02-14T14:08:56 Z mosiashvililuka Self Study (JOI22_ho_t2) C++14
100 / 100
267 ms 11968 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,lef,rig,mid,A[300009],B[300009],f[300009],M;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>M;
	for(i=1; i<=a; i++) cin>>A[i];
	for(i=1; i<=a; i++) cin>>B[i];
	for(i=1; i<=a; i++) A[i]=max(A[i],B[i]);
	lef=0;rig=1000000000000000009LL;
	while(1){
		if(lef+1>=rig) break;
		mid=(lef+rig)/2;
		for(i=1; i<=a; i++){
			f[i]=mid;
		}
		zx=0;
		for(i=1; i<=a; i++){
			if(f[i]>A[i]*M){
				f[i]-=A[i]*M;
			}else{
				c=f[i]/A[i];
				if(f[i]%A[i]!=0) c++;
				zx+=M-c;
				f[i]=max(0LL,f[i]-c*A[i]);
			}
		}
		xc=0;
		for(i=1; i<=a; i++){
			if(f[i]<=0) continue;
			c=f[i]/B[i];
			if(f[i]%B[i]!=0) c++;
			xc+=c;
			if(xc>zx) break;
		}
		if(zx>=xc){
			lef=mid;
		}else{
			rig=mid;
		}
	}
	cout<<lef;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 135 ms 11884 KB Output is correct
12 Correct 128 ms 11712 KB Output is correct
13 Correct 101 ms 8980 KB Output is correct
14 Correct 103 ms 10924 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 51 ms 7604 KB Output is correct
17 Correct 115 ms 8024 KB Output is correct
18 Correct 114 ms 8456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 51 ms 7604 KB Output is correct
3 Correct 115 ms 8024 KB Output is correct
4 Correct 114 ms 8456 KB Output is correct
5 Correct 1 ms 332 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 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 63 ms 5968 KB Output is correct
14 Correct 44 ms 3440 KB Output is correct
15 Correct 32 ms 2632 KB Output is correct
16 Correct 26 ms 2220 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 2 ms 332 KB Output is correct
23 Correct 3 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 135 ms 11884 KB Output is correct
12 Correct 128 ms 11712 KB Output is correct
13 Correct 101 ms 8980 KB Output is correct
14 Correct 103 ms 10924 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 63 ms 5968 KB Output is correct
24 Correct 44 ms 3440 KB Output is correct
25 Correct 32 ms 2632 KB Output is correct
26 Correct 26 ms 2220 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 464 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 51 ms 7604 KB Output is correct
36 Correct 115 ms 8024 KB Output is correct
37 Correct 114 ms 8456 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 3 ms 472 KB Output is correct
46 Correct 6 ms 652 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 21 ms 2048 KB Output is correct
49 Correct 0 ms 332 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 3 ms 412 KB Output is correct
52 Correct 0 ms 332 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 0 ms 204 KB Output is correct
55 Correct 65 ms 5504 KB Output is correct
56 Correct 34 ms 3168 KB Output is correct
57 Correct 34 ms 3244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 63 ms 5968 KB Output is correct
10 Correct 44 ms 3440 KB Output is correct
11 Correct 32 ms 2632 KB Output is correct
12 Correct 26 ms 2220 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 464 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 51 ms 7604 KB Output is correct
22 Correct 115 ms 8024 KB Output is correct
23 Correct 114 ms 8456 KB Output is correct
24 Correct 33 ms 1740 KB Output is correct
25 Correct 90 ms 4308 KB Output is correct
26 Correct 16 ms 1148 KB Output is correct
27 Correct 138 ms 8976 KB Output is correct
28 Correct 126 ms 9060 KB Output is correct
29 Correct 164 ms 9168 KB Output is correct
30 Correct 150 ms 9184 KB Output is correct
31 Correct 267 ms 10332 KB Output is correct
32 Correct 106 ms 7968 KB Output is correct
33 Correct 256 ms 9120 KB Output is correct
34 Correct 96 ms 7300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 135 ms 11884 KB Output is correct
12 Correct 128 ms 11712 KB Output is correct
13 Correct 101 ms 8980 KB Output is correct
14 Correct 103 ms 10924 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 63 ms 5968 KB Output is correct
24 Correct 44 ms 3440 KB Output is correct
25 Correct 32 ms 2632 KB Output is correct
26 Correct 26 ms 2220 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 332 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 2 ms 332 KB Output is correct
33 Correct 3 ms 464 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 332 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 3 ms 472 KB Output is correct
42 Correct 6 ms 652 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 21 ms 2048 KB Output is correct
45 Correct 0 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 3 ms 412 KB Output is correct
48 Correct 0 ms 332 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 0 ms 204 KB Output is correct
51 Correct 65 ms 5504 KB Output is correct
52 Correct 34 ms 3168 KB Output is correct
53 Correct 34 ms 3244 KB Output is correct
54 Correct 33 ms 1740 KB Output is correct
55 Correct 90 ms 4308 KB Output is correct
56 Correct 16 ms 1148 KB Output is correct
57 Correct 138 ms 8976 KB Output is correct
58 Correct 126 ms 9060 KB Output is correct
59 Correct 164 ms 9168 KB Output is correct
60 Correct 150 ms 9184 KB Output is correct
61 Correct 267 ms 10332 KB Output is correct
62 Correct 106 ms 7968 KB Output is correct
63 Correct 256 ms 9120 KB Output is correct
64 Correct 96 ms 7300 KB Output is correct
65 Correct 0 ms 332 KB Output is correct
66 Correct 51 ms 7604 KB Output is correct
67 Correct 115 ms 8024 KB Output is correct
68 Correct 114 ms 8456 KB Output is correct
69 Correct 28 ms 1212 KB Output is correct
70 Correct 6 ms 460 KB Output is correct
71 Correct 0 ms 332 KB Output is correct
72 Correct 34 ms 1568 KB Output is correct
73 Correct 8 ms 716 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 124 ms 9360 KB Output is correct
76 Correct 154 ms 9192 KB Output is correct
77 Correct 149 ms 8528 KB Output is correct
78 Correct 176 ms 7656 KB Output is correct
79 Correct 237 ms 9032 KB Output is correct
80 Correct 260 ms 11968 KB Output is correct
81 Correct 238 ms 8860 KB Output is correct
82 Correct 232 ms 9184 KB Output is correct