답안 #595230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
595230 2022-07-13T12:53:59 Z PoPularPlusPlus Self Study (JOI22_ho_t2) C++17
100 / 100
238 ms 10808 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long 
#define pb(e) push_back(e)
#define sv(a) sort(a.begin(),a.end())
#define sa(a,n) sort(a,a+n)
#define mp(a,b) make_pair(a,b)
#define vf first
#define vs second
#define ar array
#define all(x) x.begin(),x.end()
const int inf = 0x3f3f3f3f;
const int mod = 1000000007; 
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
bool remender(ll a , ll b){return a%b;}

//freopen("problemname.in", "r", stdin);
//freopen("problemname.out", "w", stdout);

void solve(){
	ll n , m;
	cin >> n >> m;
	ll arr[n] , b[n];
	for(int i = 0; i < n; i++)cin >> arr[i];
	for(int i = 0; i < n; i++)cin >> b[i];
	ll l = 1,  r = 1e18 , ans;
	while(l <= r){
		ll mid = (l + r)/2;
		ll chance = 0;
		for(int i = 0; i < n; i++){
			ll sum = max(arr[i] , b[i]) * m;
			if(sum <= mid){
				ll x = mid - sum;
				chance -= x / b[i] + remender(x , b[i]);
			}
			else {
				ll need = mid / max(arr[i] , b[i]) + remender(mid , max(arr[i] , b[i]));
				chance += m - need;
			}
			if(chance + n * m < 0)break;
		}
		if(chance >= 0){
			ans = mid;
			l = mid + 1;
		}
		else r = mid - 1;
	}
	cout << ans << '\n';
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
	//int t;cin >> t;while(t--)
	solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 96 ms 5000 KB Output is correct
12 Correct 102 ms 5004 KB Output is correct
13 Correct 96 ms 5008 KB Output is correct
14 Correct 74 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 31 ms 4948 KB Output is correct
17 Correct 112 ms 4992 KB Output is correct
18 Correct 94 ms 5004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 31 ms 4948 KB Output is correct
3 Correct 112 ms 4992 KB Output is correct
4 Correct 94 ms 5004 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 48 ms 2644 KB Output is correct
14 Correct 32 ms 1876 KB Output is correct
15 Correct 24 ms 1488 KB Output is correct
16 Correct 20 ms 1236 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 96 ms 5000 KB Output is correct
12 Correct 102 ms 5004 KB Output is correct
13 Correct 96 ms 5008 KB Output is correct
14 Correct 74 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 48 ms 2644 KB Output is correct
24 Correct 32 ms 1876 KB Output is correct
25 Correct 24 ms 1488 KB Output is correct
26 Correct 20 ms 1236 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 31 ms 4948 KB Output is correct
36 Correct 112 ms 4992 KB Output is correct
37 Correct 94 ms 5004 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 4 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 24 ms 1236 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 2 ms 340 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 48 ms 2516 KB Output is correct
56 Correct 33 ms 1880 KB Output is correct
57 Correct 25 ms 1876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 48 ms 2644 KB Output is correct
10 Correct 32 ms 1876 KB Output is correct
11 Correct 24 ms 1488 KB Output is correct
12 Correct 20 ms 1236 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 31 ms 4948 KB Output is correct
22 Correct 112 ms 4992 KB Output is correct
23 Correct 94 ms 5004 KB Output is correct
24 Correct 28 ms 1040 KB Output is correct
25 Correct 68 ms 2396 KB Output is correct
26 Correct 13 ms 724 KB Output is correct
27 Correct 111 ms 4992 KB Output is correct
28 Correct 101 ms 4992 KB Output is correct
29 Correct 98 ms 4992 KB Output is correct
30 Correct 124 ms 4996 KB Output is correct
31 Correct 209 ms 4948 KB Output is correct
32 Correct 108 ms 5788 KB Output is correct
33 Correct 238 ms 5892 KB Output is correct
34 Correct 106 ms 6168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 96 ms 5000 KB Output is correct
12 Correct 102 ms 5004 KB Output is correct
13 Correct 96 ms 5008 KB Output is correct
14 Correct 74 ms 4948 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 48 ms 2644 KB Output is correct
24 Correct 32 ms 1876 KB Output is correct
25 Correct 24 ms 1488 KB Output is correct
26 Correct 20 ms 1236 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 2 ms 340 KB Output is correct
42 Correct 4 ms 340 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 24 ms 1236 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 48 ms 2516 KB Output is correct
52 Correct 33 ms 1880 KB Output is correct
53 Correct 25 ms 1876 KB Output is correct
54 Correct 28 ms 1040 KB Output is correct
55 Correct 68 ms 2396 KB Output is correct
56 Correct 13 ms 724 KB Output is correct
57 Correct 111 ms 4992 KB Output is correct
58 Correct 101 ms 4992 KB Output is correct
59 Correct 98 ms 4992 KB Output is correct
60 Correct 124 ms 4996 KB Output is correct
61 Correct 209 ms 4948 KB Output is correct
62 Correct 108 ms 5788 KB Output is correct
63 Correct 238 ms 5892 KB Output is correct
64 Correct 106 ms 6168 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 31 ms 4948 KB Output is correct
67 Correct 112 ms 4992 KB Output is correct
68 Correct 94 ms 5004 KB Output is correct
69 Correct 22 ms 1448 KB Output is correct
70 Correct 7 ms 596 KB Output is correct
71 Correct 0 ms 316 KB Output is correct
72 Correct 32 ms 1740 KB Output is correct
73 Correct 7 ms 584 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 114 ms 10740 KB Output is correct
76 Correct 111 ms 10808 KB Output is correct
77 Correct 121 ms 10736 KB Output is correct
78 Correct 164 ms 10788 KB Output is correct
79 Correct 214 ms 10700 KB Output is correct
80 Correct 231 ms 10784 KB Output is correct
81 Correct 219 ms 8912 KB Output is correct
82 Correct 219 ms 8784 KB Output is correct