답안 #531714

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531714 2022-03-01T10:20:46 Z errorgorn Self Study (JOI22_ho_t2) C++17
100 / 100
376 ms 11412 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

ll n,m;
ll arr[300005];
ll brr[300005];

bool can(ll val){
	__int128 extra=0;
	
	rep(x,0,n){
		ll temp=(val+arr[x]-1)/arr[x];
		
		if (temp<=m) extra+=m-temp;
		else{
			ll nv=val-m*arr[x];
			extra-=(nv+brr[x]-1)/brr[x];
		}
	}
	
	return extra>=0;
}

signed main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n>>m;
	rep(x,0,n) cin>>arr[x];
	rep(x,0,n) cin>>brr[x];
	
	rep(x,0,n) assert(brr[x]>0);
	
	rep(x,0,n) arr[x]=max(arr[x],brr[x]);
	
	ll lo=0,hi=1e18+100,mi;
	while (hi-lo>1){
		mi=hi+lo>>1;
		
		if (can(mi)) lo=mi;
		else hi=mi;
	}
	
	cout<<lo<<endl;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:58:8: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |   mi=hi+lo>>1;
      |      ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 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 324 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 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 226 ms 10620 KB Output is correct
12 Correct 236 ms 10704 KB Output is correct
13 Correct 242 ms 8720 KB Output is correct
14 Correct 288 ms 8868 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 357 ms 6172 KB Output is correct
17 Correct 270 ms 11272 KB Output is correct
18 Correct 229 ms 10440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 357 ms 6172 KB Output is correct
3 Correct 270 ms 11272 KB Output is correct
4 Correct 229 ms 10440 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 320 KB Output is correct
13 Correct 119 ms 5440 KB Output is correct
14 Correct 80 ms 3796 KB Output is correct
15 Correct 59 ms 2876 KB Output is correct
16 Correct 50 ms 2388 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 7 ms 332 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 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 324 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 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 226 ms 10620 KB Output is correct
12 Correct 236 ms 10704 KB Output is correct
13 Correct 242 ms 8720 KB Output is correct
14 Correct 288 ms 8868 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 320 KB Output is correct
23 Correct 119 ms 5440 KB Output is correct
24 Correct 80 ms 3796 KB Output is correct
25 Correct 59 ms 2876 KB Output is correct
26 Correct 50 ms 2388 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 7 ms 332 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 357 ms 6172 KB Output is correct
36 Correct 270 ms 11272 KB Output is correct
37 Correct 229 ms 10440 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 0 ms 332 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 332 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 324 KB Output is correct
45 Correct 5 ms 460 KB Output is correct
46 Correct 7 ms 588 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 42 ms 2004 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 4 ms 416 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 117 ms 5444 KB Output is correct
56 Correct 85 ms 3120 KB Output is correct
57 Correct 97 ms 3012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 0 ms 320 KB Output is correct
9 Correct 119 ms 5440 KB Output is correct
10 Correct 80 ms 3796 KB Output is correct
11 Correct 59 ms 2876 KB Output is correct
12 Correct 50 ms 2388 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 7 ms 332 KB Output is correct
19 Correct 5 ms 460 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 357 ms 6172 KB Output is correct
22 Correct 270 ms 11272 KB Output is correct
23 Correct 229 ms 10440 KB Output is correct
24 Correct 38 ms 1864 KB Output is correct
25 Correct 117 ms 5004 KB Output is correct
26 Correct 26 ms 1476 KB Output is correct
27 Correct 233 ms 10692 KB Output is correct
28 Correct 232 ms 10784 KB Output is correct
29 Correct 241 ms 10820 KB Output is correct
30 Correct 238 ms 10688 KB Output is correct
31 Correct 230 ms 10616 KB Output is correct
32 Correct 352 ms 6176 KB Output is correct
33 Correct 255 ms 11412 KB Output is correct
34 Correct 376 ms 6172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 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 324 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 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 4 ms 460 KB Output is correct
11 Correct 226 ms 10620 KB Output is correct
12 Correct 236 ms 10704 KB Output is correct
13 Correct 242 ms 8720 KB Output is correct
14 Correct 288 ms 8868 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 328 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 0 ms 320 KB Output is correct
23 Correct 119 ms 5440 KB Output is correct
24 Correct 80 ms 3796 KB Output is correct
25 Correct 59 ms 2876 KB Output is correct
26 Correct 50 ms 2388 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 7 ms 332 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 0 ms 332 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 332 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 324 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 7 ms 588 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 42 ms 2004 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 4 ms 416 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 117 ms 5444 KB Output is correct
52 Correct 85 ms 3120 KB Output is correct
53 Correct 97 ms 3012 KB Output is correct
54 Correct 38 ms 1864 KB Output is correct
55 Correct 117 ms 5004 KB Output is correct
56 Correct 26 ms 1476 KB Output is correct
57 Correct 233 ms 10692 KB Output is correct
58 Correct 232 ms 10784 KB Output is correct
59 Correct 241 ms 10820 KB Output is correct
60 Correct 238 ms 10688 KB Output is correct
61 Correct 230 ms 10616 KB Output is correct
62 Correct 352 ms 6176 KB Output is correct
63 Correct 255 ms 11412 KB Output is correct
64 Correct 376 ms 6172 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 357 ms 6172 KB Output is correct
67 Correct 270 ms 11272 KB Output is correct
68 Correct 229 ms 10440 KB Output is correct
69 Correct 30 ms 1400 KB Output is correct
70 Correct 7 ms 588 KB Output is correct
71 Correct 1 ms 332 KB Output is correct
72 Correct 47 ms 1732 KB Output is correct
73 Correct 10 ms 588 KB Output is correct
74 Correct 2 ms 332 KB Output is correct
75 Correct 242 ms 10684 KB Output is correct
76 Correct 251 ms 10760 KB Output is correct
77 Correct 241 ms 10748 KB Output is correct
78 Correct 249 ms 10684 KB Output is correct
79 Correct 259 ms 10768 KB Output is correct
80 Correct 284 ms 10724 KB Output is correct
81 Correct 241 ms 8876 KB Output is correct
82 Correct 225 ms 8812 KB Output is correct