답안 #907634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
907634 2024-01-16T00:57:24 Z vjudge1 Self Study (JOI22_ho_t2) C++17
100 / 100
350 ms 10068 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef __int128_t ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;

std::istream& operator>>( std::istream& src, __int128_t& value) {
	long long v;src>>v;
	value = (ll)v;
	return src;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	ll n,m;cin>>n>>m;
	vi a(n);rep(i,0,n)cin>>a[i];
	vi b(n);rep(i,0,n)cin>>b[i];

	bool eq = true;
	rep(i,0,n)a[i]=max(a[i],b[i]);
	ll worst = 2e18;
	if(m==1){
		rep(i,0,n) worst=min(worst,a[i]);
	}else{
		ll lo = 0;
		ll hi = 2e18;
		while(lo+1<hi){
			ll mid = lo+(hi-lo)/2;
			ll cost = 0;
			rep(i,0,n) {
				ll inclass = (mid+a[i]-1)/a[i];
				if(inclass>m){
					inclass=m;
					ll outclass = (mid-inclass*a[i]+b[i]-1)/b[i];
					cost+=outclass;
				}
				cost+=inclass;
			}
			if(cost<=n*m) lo=mid;
			else hi=mid;
		}
		worst=lo;
	}
	cout<<(long long)worst<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:27:7: warning: unused variable 'eq' [-Wunused-variable]
   27 |  bool eq = true;
      |       ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 55 ms 9820 KB Output is correct
12 Correct 48 ms 9820 KB Output is correct
13 Correct 38 ms 9820 KB Output is correct
14 Correct 37 ms 9808 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 26 ms 9820 KB Output is correct
17 Correct 69 ms 10008 KB Output is correct
18 Correct 48 ms 9816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 26 ms 9820 KB Output is correct
3 Correct 69 ms 10008 KB Output is correct
4 Correct 48 ms 9816 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 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 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 114 ms 5144 KB Output is correct
14 Correct 75 ms 3420 KB Output is correct
15 Correct 55 ms 2652 KB Output is correct
16 Correct 45 ms 2140 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 6 ms 604 KB Output is correct
23 Correct 4 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 55 ms 9820 KB Output is correct
12 Correct 48 ms 9820 KB Output is correct
13 Correct 38 ms 9820 KB Output is correct
14 Correct 37 ms 9808 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 114 ms 5144 KB Output is correct
24 Correct 75 ms 3420 KB Output is correct
25 Correct 55 ms 2652 KB Output is correct
26 Correct 45 ms 2140 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 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 6 ms 604 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 26 ms 9820 KB Output is correct
36 Correct 69 ms 10008 KB Output is correct
37 Correct 48 ms 9816 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 452 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 5 ms 604 KB Output is correct
46 Correct 7 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 39 ms 2048 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 111 ms 5104 KB Output is correct
56 Correct 73 ms 3420 KB Output is correct
57 Correct 90 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 114 ms 5144 KB Output is correct
10 Correct 75 ms 3420 KB Output is correct
11 Correct 55 ms 2652 KB Output is correct
12 Correct 45 ms 2140 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 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 6 ms 604 KB Output is correct
19 Correct 4 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 26 ms 9820 KB Output is correct
22 Correct 69 ms 10008 KB Output is correct
23 Correct 48 ms 9816 KB Output is correct
24 Correct 36 ms 1880 KB Output is correct
25 Correct 105 ms 4656 KB Output is correct
26 Correct 24 ms 1372 KB Output is correct
27 Correct 214 ms 9844 KB Output is correct
28 Correct 230 ms 10068 KB Output is correct
29 Correct 222 ms 9812 KB Output is correct
30 Correct 227 ms 9836 KB Output is correct
31 Correct 216 ms 9776 KB Output is correct
32 Correct 335 ms 9836 KB Output is correct
33 Correct 309 ms 9840 KB Output is correct
34 Correct 349 ms 9840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 55 ms 9820 KB Output is correct
12 Correct 48 ms 9820 KB Output is correct
13 Correct 38 ms 9820 KB Output is correct
14 Correct 37 ms 9808 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 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 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 114 ms 5144 KB Output is correct
24 Correct 75 ms 3420 KB Output is correct
25 Correct 55 ms 2652 KB Output is correct
26 Correct 45 ms 2140 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 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 6 ms 604 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 452 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 344 KB Output is correct
38 Correct 1 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 5 ms 604 KB Output is correct
42 Correct 7 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 39 ms 2048 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 4 ms 600 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 111 ms 5104 KB Output is correct
52 Correct 73 ms 3420 KB Output is correct
53 Correct 90 ms 3416 KB Output is correct
54 Correct 36 ms 1880 KB Output is correct
55 Correct 105 ms 4656 KB Output is correct
56 Correct 24 ms 1372 KB Output is correct
57 Correct 214 ms 9844 KB Output is correct
58 Correct 230 ms 10068 KB Output is correct
59 Correct 222 ms 9812 KB Output is correct
60 Correct 227 ms 9836 KB Output is correct
61 Correct 216 ms 9776 KB Output is correct
62 Correct 335 ms 9836 KB Output is correct
63 Correct 309 ms 9840 KB Output is correct
64 Correct 349 ms 9840 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 26 ms 9820 KB Output is correct
67 Correct 69 ms 10008 KB Output is correct
68 Correct 48 ms 9816 KB Output is correct
69 Correct 26 ms 1368 KB Output is correct
70 Correct 7 ms 604 KB Output is correct
71 Correct 1 ms 344 KB Output is correct
72 Correct 35 ms 1624 KB Output is correct
73 Correct 8 ms 600 KB Output is correct
74 Correct 1 ms 344 KB Output is correct
75 Correct 222 ms 9836 KB Output is correct
76 Correct 222 ms 9816 KB Output is correct
77 Correct 226 ms 9836 KB Output is correct
78 Correct 245 ms 10064 KB Output is correct
79 Correct 243 ms 9808 KB Output is correct
80 Correct 246 ms 9808 KB Output is correct
81 Correct 294 ms 10068 KB Output is correct
82 Correct 350 ms 9812 KB Output is correct