답안 #923971

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923971 2024-02-08T07:18:18 Z Xiaoyang Self Study (JOI22_ho_t2) C++17
100 / 100
207 ms 11852 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 1ll<<60
#define rep(i,a,b) for (ll i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
#define endl "\n"
void inc(ll &a,ll b) {a=(a+b)%mod;}
void dec(ll &a,ll b) {a=(a-b+mod)%mod;}
int prod(ll a,ll b) {return ll(a)*ll(b)%mod;}
int lowbit(ll x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
const ll maxn=333333;
ll a[maxn],b[maxn];
ll n,m;
 
ll dv(ll x,ll y){
	return (x+y-1)/y;
}
bool check(ll mid){//returns if the minimum can be met
	ll cnt=0;
	rep(i,1,n+1){
		ll curr=mid;
		if(a[i]>b[i]){
			curr-=min(dv(mid,a[i]),m)*a[i];
			cnt+=min(dv(mid,a[i]),m);
		}
		if(curr>0){
			cnt+=dv(curr,b[i]);
		}
		if(cnt>m*n)return 0;
	}
	return cnt<=m*n;
}
 
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	rep(i,1,n+1)cin>>a[i];
	rep(i,1,n+1)cin>>b[i];
	
	ll lo=1,hi=1e18;
	while(lo<hi){
		ll mid=(lo+hi+1)>>1;
		if(check(mid))lo=mid;
		else hi=mid-1;
	}
	
	cout<<lo<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 90 ms 5212 KB Output is correct
12 Correct 92 ms 5212 KB Output is correct
13 Correct 64 ms 5208 KB Output is correct
14 Correct 60 ms 5404 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 23 ms 5208 KB Output is correct
17 Correct 86 ms 11852 KB Output is correct
18 Correct 81 ms 11344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 23 ms 5208 KB Output is correct
3 Correct 86 ms 11852 KB Output is correct
4 Correct 81 ms 11344 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 41 ms 4952 KB Output is correct
14 Correct 28 ms 4700 KB Output is correct
15 Correct 20 ms 4700 KB Output is correct
16 Correct 17 ms 4700 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 90 ms 5212 KB Output is correct
12 Correct 92 ms 5212 KB Output is correct
13 Correct 64 ms 5208 KB Output is correct
14 Correct 60 ms 5404 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 41 ms 4952 KB Output is correct
24 Correct 28 ms 4700 KB Output is correct
25 Correct 20 ms 4700 KB Output is correct
26 Correct 17 ms 4700 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2392 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 23 ms 5208 KB Output is correct
36 Correct 86 ms 11852 KB Output is correct
37 Correct 81 ms 11344 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 1 ms 2512 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 3 ms 2652 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 21 ms 5696 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2512 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 50 ms 7488 KB Output is correct
56 Correct 26 ms 5980 KB Output is correct
57 Correct 21 ms 5968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 41 ms 4952 KB Output is correct
10 Correct 28 ms 4700 KB Output is correct
11 Correct 20 ms 4700 KB Output is correct
12 Correct 17 ms 4700 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 2 ms 2392 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 23 ms 5208 KB Output is correct
22 Correct 86 ms 11852 KB Output is correct
23 Correct 81 ms 11344 KB Output is correct
24 Correct 27 ms 5588 KB Output is correct
25 Correct 62 ms 7152 KB Output is correct
26 Correct 11 ms 5164 KB Output is correct
27 Correct 84 ms 11096 KB Output is correct
28 Correct 84 ms 11196 KB Output is correct
29 Correct 102 ms 11188 KB Output is correct
30 Correct 112 ms 11136 KB Output is correct
31 Correct 180 ms 11188 KB Output is correct
32 Correct 104 ms 6480 KB Output is correct
33 Correct 207 ms 11600 KB Output is correct
34 Correct 102 ms 6568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 90 ms 5212 KB Output is correct
12 Correct 92 ms 5212 KB Output is correct
13 Correct 64 ms 5208 KB Output is correct
14 Correct 60 ms 5404 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 41 ms 4952 KB Output is correct
24 Correct 28 ms 4700 KB Output is correct
25 Correct 20 ms 4700 KB Output is correct
26 Correct 17 ms 4700 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 2 ms 2392 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 1 ms 2512 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 3 ms 2652 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 21 ms 5696 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2512 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 50 ms 7488 KB Output is correct
52 Correct 26 ms 5980 KB Output is correct
53 Correct 21 ms 5968 KB Output is correct
54 Correct 27 ms 5588 KB Output is correct
55 Correct 62 ms 7152 KB Output is correct
56 Correct 11 ms 5164 KB Output is correct
57 Correct 84 ms 11096 KB Output is correct
58 Correct 84 ms 11196 KB Output is correct
59 Correct 102 ms 11188 KB Output is correct
60 Correct 112 ms 11136 KB Output is correct
61 Correct 180 ms 11188 KB Output is correct
62 Correct 104 ms 6480 KB Output is correct
63 Correct 207 ms 11600 KB Output is correct
64 Correct 102 ms 6568 KB Output is correct
65 Correct 1 ms 2392 KB Output is correct
66 Correct 23 ms 5208 KB Output is correct
67 Correct 86 ms 11852 KB Output is correct
68 Correct 81 ms 11344 KB Output is correct
69 Correct 20 ms 5212 KB Output is correct
70 Correct 6 ms 2648 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 30 ms 5444 KB Output is correct
73 Correct 6 ms 2848 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 103 ms 11068 KB Output is correct
76 Correct 111 ms 11196 KB Output is correct
77 Correct 122 ms 11088 KB Output is correct
78 Correct 148 ms 11052 KB Output is correct
79 Correct 200 ms 11068 KB Output is correct
80 Correct 204 ms 11088 KB Output is correct
81 Correct 195 ms 9208 KB Output is correct
82 Correct 195 ms 9348 KB Output is correct