Submission #532659

# Submission time Handle Problem Language Result Execution time Memory
532659 2022-03-03T14:57:13 Z victor_gao Self Study (JOI22_ho_t2) C++17
62 / 100
257 ms 11444 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 300015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int a[N],b[N],n,m;
bool check(int val){
	int cnt=0;
	for (int i=1;i<=n;i++){
		if (a[i]>b[i]){
			if (a[i]*m<val){
				cnt+=m;
				int newval=val-a[i]*m;
				cnt+=(newval/b[i]+(newval%b[i]>0));		
			}
			else cnt+=(val/a[i]+(val%a[i]>0));
		}
		else {
			cnt+=(val/b[i]+(val%b[i]>0));
		}
		if (cnt>m*n) return 0;
	}
	return cnt<=m*n;
}
signed main(){
	fast
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	int l=0,r=1e18;
	while (l<r){
		int mid=(l+r)>>1;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	cout<<l-1<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 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 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 108 ms 5060 KB Output is correct
12 Correct 110 ms 5128 KB Output is correct
13 Correct 82 ms 5084 KB Output is correct
14 Correct 91 ms 5188 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 33 ms 6084 KB Output is correct
17 Correct 113 ms 11332 KB Output is correct
18 Correct 105 ms 10692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 33 ms 6084 KB Output is correct
3 Correct 113 ms 11332 KB Output is correct
4 Correct 105 ms 10692 KB Output is correct
5 Correct 1 ms 332 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 0 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 50 ms 2784 KB Output is correct
14 Correct 37 ms 2004 KB Output is correct
15 Correct 27 ms 1744 KB Output is correct
16 Correct 24 ms 1356 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 3 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 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 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 108 ms 5060 KB Output is correct
12 Correct 110 ms 5128 KB Output is correct
13 Correct 82 ms 5084 KB Output is correct
14 Correct 91 ms 5188 KB Output is correct
15 Correct 1 ms 332 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 0 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 50 ms 2784 KB Output is correct
24 Correct 37 ms 2004 KB Output is correct
25 Correct 27 ms 1744 KB Output is correct
26 Correct 24 ms 1356 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 456 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 33 ms 6084 KB Output is correct
36 Correct 113 ms 11332 KB Output is correct
37 Correct 105 ms 10692 KB Output is correct
38 Correct 1 ms 324 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 1 ms 320 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 4 ms 460 KB Output is correct
46 Correct 5 ms 588 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 21 ms 2032 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 1 ms 328 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 57 ms 5448 KB Output is correct
56 Correct 35 ms 3032 KB Output is correct
57 Correct 29 ms 3116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 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 0 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 50 ms 2784 KB Output is correct
10 Correct 37 ms 2004 KB Output is correct
11 Correct 27 ms 1744 KB Output is correct
12 Correct 24 ms 1356 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 3 ms 456 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 33 ms 6084 KB Output is correct
22 Correct 113 ms 11332 KB Output is correct
23 Correct 105 ms 10692 KB Output is correct
24 Correct 37 ms 1936 KB Output is correct
25 Correct 78 ms 5004 KB Output is correct
26 Correct 13 ms 1380 KB Output is correct
27 Correct 98 ms 10692 KB Output is correct
28 Correct 112 ms 10728 KB Output is correct
29 Correct 111 ms 10792 KB Output is correct
30 Correct 132 ms 10784 KB Output is correct
31 Correct 218 ms 10792 KB Output is correct
32 Correct 118 ms 6088 KB Output is correct
33 Incorrect 257 ms 11444 KB Output isn't correct
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 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 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 460 KB Output is correct
11 Correct 108 ms 5060 KB Output is correct
12 Correct 110 ms 5128 KB Output is correct
13 Correct 82 ms 5084 KB Output is correct
14 Correct 91 ms 5188 KB Output is correct
15 Correct 1 ms 332 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 0 ms 332 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 50 ms 2784 KB Output is correct
24 Correct 37 ms 2004 KB Output is correct
25 Correct 27 ms 1744 KB Output is correct
26 Correct 24 ms 1356 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 3 ms 456 KB Output is correct
34 Correct 1 ms 324 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 1 ms 320 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 4 ms 460 KB Output is correct
42 Correct 5 ms 588 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 21 ms 2032 KB Output is correct
45 Correct 1 ms 320 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 2 ms 460 KB Output is correct
48 Correct 1 ms 328 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 57 ms 5448 KB Output is correct
52 Correct 35 ms 3032 KB Output is correct
53 Correct 29 ms 3116 KB Output is correct
54 Correct 37 ms 1936 KB Output is correct
55 Correct 78 ms 5004 KB Output is correct
56 Correct 13 ms 1380 KB Output is correct
57 Correct 98 ms 10692 KB Output is correct
58 Correct 112 ms 10728 KB Output is correct
59 Correct 111 ms 10792 KB Output is correct
60 Correct 132 ms 10784 KB Output is correct
61 Correct 218 ms 10792 KB Output is correct
62 Correct 118 ms 6088 KB Output is correct
63 Incorrect 257 ms 11444 KB Output isn't correct
64 Halted 0 ms 0 KB -