답안 #532661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532661 2022-03-03T14:59:08 Z victor_gao Self Study (JOI22_ho_t2) C++17
100 / 100
283 ms 10796 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(unsigned long long val){
	int cnt=0;
	for (int i=1;i<=n;i++){
		if (a[i]>b[i]){
			if (a[i]*m<val){
				cnt+=m;
				unsigned long long 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];
	unsigned long long l=0,r=5e18;
	while (l<r){
		int mid=(l+r)>>1;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	cout<<l-1<<'\n';
}

Compilation message

Main.cpp: In function 'bool check(long long unsigned int)':
Main.cpp:22:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   22 |    if (a[i]*m<val){
      |        ~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 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 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 129 ms 5700 KB Output is correct
12 Correct 150 ms 5768 KB Output is correct
13 Correct 100 ms 5760 KB Output is correct
14 Correct 88 ms 5764 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 34 ms 5628 KB Output is correct
17 Correct 141 ms 5704 KB Output is correct
18 Correct 100 ms 5636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 34 ms 5628 KB Output is correct
3 Correct 141 ms 5704 KB Output is correct
4 Correct 100 ms 5636 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 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 332 KB Output is correct
13 Correct 59 ms 3412 KB Output is correct
14 Correct 38 ms 2604 KB Output is correct
15 Correct 27 ms 2388 KB Output is correct
16 Correct 24 ms 2116 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 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 464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 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 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 129 ms 5700 KB Output is correct
12 Correct 150 ms 5768 KB Output is correct
13 Correct 100 ms 5760 KB Output is correct
14 Correct 88 ms 5764 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 324 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 332 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 332 KB Output is correct
23 Correct 59 ms 3412 KB Output is correct
24 Correct 38 ms 2604 KB Output is correct
25 Correct 27 ms 2388 KB Output is correct
26 Correct 24 ms 2116 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 332 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 464 KB Output is correct
34 Correct 1 ms 324 KB Output is correct
35 Correct 34 ms 5628 KB Output is correct
36 Correct 141 ms 5704 KB Output is correct
37 Correct 100 ms 5636 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 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 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 4 ms 432 KB Output is correct
46 Correct 4 ms 588 KB Output is correct
47 Correct 1 ms 328 KB Output is correct
48 Correct 22 ms 1724 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 4 ms 460 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 62 ms 3164 KB Output is correct
56 Correct 36 ms 2400 KB Output is correct
57 Correct 29 ms 2412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 204 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 59 ms 3412 KB Output is correct
10 Correct 38 ms 2604 KB Output is correct
11 Correct 27 ms 2388 KB Output is correct
12 Correct 24 ms 2116 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 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 464 KB Output is correct
20 Correct 1 ms 324 KB Output is correct
21 Correct 34 ms 5628 KB Output is correct
22 Correct 141 ms 5704 KB Output is correct
23 Correct 100 ms 5636 KB Output is correct
24 Correct 33 ms 1840 KB Output is correct
25 Correct 90 ms 3052 KB Output is correct
26 Correct 16 ms 1348 KB Output is correct
27 Correct 131 ms 5620 KB Output is correct
28 Correct 135 ms 5640 KB Output is correct
29 Correct 121 ms 5528 KB Output is correct
30 Correct 139 ms 5576 KB Output is correct
31 Correct 230 ms 5828 KB Output is correct
32 Correct 145 ms 5536 KB Output is correct
33 Correct 283 ms 5640 KB Output is correct
34 Correct 133 ms 6152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 332 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 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 464 KB Output is correct
11 Correct 129 ms 5700 KB Output is correct
12 Correct 150 ms 5768 KB Output is correct
13 Correct 100 ms 5760 KB Output is correct
14 Correct 88 ms 5764 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 324 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 332 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 332 KB Output is correct
23 Correct 59 ms 3412 KB Output is correct
24 Correct 38 ms 2604 KB Output is correct
25 Correct 27 ms 2388 KB Output is correct
26 Correct 24 ms 2116 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 320 KB Output is correct
29 Correct 1 ms 324 KB Output is correct
30 Correct 1 ms 332 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 464 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 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 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 4 ms 432 KB Output is correct
42 Correct 4 ms 588 KB Output is correct
43 Correct 1 ms 328 KB Output is correct
44 Correct 22 ms 1724 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 460 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 62 ms 3164 KB Output is correct
52 Correct 36 ms 2400 KB Output is correct
53 Correct 29 ms 2412 KB Output is correct
54 Correct 33 ms 1840 KB Output is correct
55 Correct 90 ms 3052 KB Output is correct
56 Correct 16 ms 1348 KB Output is correct
57 Correct 131 ms 5620 KB Output is correct
58 Correct 135 ms 5640 KB Output is correct
59 Correct 121 ms 5528 KB Output is correct
60 Correct 139 ms 5576 KB Output is correct
61 Correct 230 ms 5828 KB Output is correct
62 Correct 145 ms 5536 KB Output is correct
63 Correct 283 ms 5640 KB Output is correct
64 Correct 133 ms 6152 KB Output is correct
65 Correct 1 ms 324 KB Output is correct
66 Correct 34 ms 5628 KB Output is correct
67 Correct 141 ms 5704 KB Output is correct
68 Correct 100 ms 5636 KB Output is correct
69 Correct 25 ms 1336 KB Output is correct
70 Correct 7 ms 584 KB Output is correct
71 Correct 1 ms 320 KB Output is correct
72 Correct 37 ms 1820 KB Output is correct
73 Correct 9 ms 588 KB Output is correct
74 Correct 1 ms 336 KB Output is correct
75 Correct 125 ms 10700 KB Output is correct
76 Correct 144 ms 10796 KB Output is correct
77 Correct 143 ms 10792 KB Output is correct
78 Correct 187 ms 10796 KB Output is correct
79 Correct 269 ms 10704 KB Output is correct
80 Correct 277 ms 10792 KB Output is correct
81 Correct 272 ms 8792 KB Output is correct
82 Correct 195 ms 8908 KB Output is correct