Submission #651866

# Submission time Handle Problem Language Result Execution time Memory
651866 2022-10-20T11:08:18 Z beaconmc Self Study (JOI22_ho_t2) C++11
100 / 100
437 ms 14960 KB
#include <bits/stdc++.h>

typedef long long ll;

using namespace std;


#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)


#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

ll n,m;
vector<ll> lis;
vector<ll> lis2;

bool check(ll a){
	ll cnt = 0;


	FOR(i,0,n){
		if (lis[i] > lis2[i]){
			if (a>lis[i]*m){
				cnt += ceil((a-(lis[i]*m))/lis2[i]) + m + !!((a-(lis[i]*m))%lis2[i]);
			}else{
				cnt += ceil(a/lis[i]) + !!(a%lis[i]);
			}
		}else{
			cnt += ceil(a/lis2[i]) + !!(a%lis2[i]);
		}
		if (cnt > n*m){
			return false;
		}
	}


	if (cnt <= n*m){
		return true;
	}return false;
}

int main(){
	cin >> n >> m;
	FOR(i,0,n){
		ll temp; cin >> temp;
		lis.push_back(temp);
	}
	FOR(i,0,n){
		ll temp; cin >> temp;
		lis2.push_back(temp);
	}


	ll lo = 0;
	ll hi = 1000000000000000000;

	while (lo<hi){
		ll mid = (lo+hi+1)/2;
		if (check(mid)){
			lo = mid;
		}else{
			hi = mid - 1;
		}
	}
	cout << lo;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 281 ms 8680 KB Output is correct
12 Correct 278 ms 8732 KB Output is correct
13 Correct 215 ms 8752 KB Output is correct
14 Correct 186 ms 8716 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 85 ms 9964 KB Output is correct
17 Correct 301 ms 14960 KB Output is correct
18 Correct 279 ms 14328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 85 ms 9964 KB Output is correct
3 Correct 301 ms 14960 KB Output is correct
4 Correct 279 ms 14328 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 1 ms 212 KB Output is correct
10 Correct 1 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 138 ms 4472 KB Output is correct
14 Correct 92 ms 2568 KB Output is correct
15 Correct 67 ms 2392 KB Output is correct
16 Correct 60 ms 1532 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 1 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 281 ms 8680 KB Output is correct
12 Correct 278 ms 8732 KB Output is correct
13 Correct 215 ms 8752 KB Output is correct
14 Correct 186 ms 8716 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 1 ms 212 KB Output is correct
20 Correct 1 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 138 ms 4472 KB Output is correct
24 Correct 92 ms 2568 KB Output is correct
25 Correct 67 ms 2392 KB Output is correct
26 Correct 60 ms 1532 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 85 ms 9964 KB Output is correct
36 Correct 301 ms 14960 KB Output is correct
37 Correct 279 ms 14328 KB Output is correct
38 Correct 1 ms 280 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 2 ms 212 KB Output is correct
43 Correct 2 ms 212 KB Output is correct
44 Correct 1 ms 300 KB Output is correct
45 Correct 7 ms 468 KB Output is correct
46 Correct 10 ms 724 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 56 ms 2352 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 2 ms 296 KB Output is correct
51 Correct 7 ms 468 KB Output is correct
52 Correct 2 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 300 KB Output is correct
55 Correct 150 ms 7412 KB Output is correct
56 Correct 74 ms 3652 KB Output is correct
57 Correct 74 ms 3816 KB Output is correct
# Verdict Execution time Memory 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 1 ms 212 KB Output is correct
6 Correct 1 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 138 ms 4472 KB Output is correct
10 Correct 92 ms 2568 KB Output is correct
11 Correct 67 ms 2392 KB Output is correct
12 Correct 60 ms 1532 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 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 2 ms 340 KB Output is correct
19 Correct 6 ms 468 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 85 ms 9964 KB Output is correct
22 Correct 301 ms 14960 KB Output is correct
23 Correct 279 ms 14328 KB Output is correct
24 Correct 63 ms 2304 KB Output is correct
25 Correct 151 ms 7084 KB Output is correct
26 Correct 33 ms 1544 KB Output is correct
27 Correct 308 ms 14332 KB Output is correct
28 Correct 284 ms 14316 KB Output is correct
29 Correct 278 ms 14344 KB Output is correct
30 Correct 315 ms 14348 KB Output is correct
31 Correct 384 ms 14388 KB Output is correct
32 Correct 219 ms 9924 KB Output is correct
33 Correct 437 ms 14948 KB Output is correct
34 Correct 204 ms 9904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 1 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 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 281 ms 8680 KB Output is correct
12 Correct 278 ms 8732 KB Output is correct
13 Correct 215 ms 8752 KB Output is correct
14 Correct 186 ms 8716 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 1 ms 212 KB Output is correct
20 Correct 1 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 138 ms 4472 KB Output is correct
24 Correct 92 ms 2568 KB Output is correct
25 Correct 67 ms 2392 KB Output is correct
26 Correct 60 ms 1532 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 468 KB Output is correct
34 Correct 1 ms 280 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 2 ms 212 KB Output is correct
39 Correct 2 ms 212 KB Output is correct
40 Correct 1 ms 300 KB Output is correct
41 Correct 7 ms 468 KB Output is correct
42 Correct 10 ms 724 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 56 ms 2352 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 2 ms 296 KB Output is correct
47 Correct 7 ms 468 KB Output is correct
48 Correct 2 ms 340 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 300 KB Output is correct
51 Correct 150 ms 7412 KB Output is correct
52 Correct 74 ms 3652 KB Output is correct
53 Correct 74 ms 3816 KB Output is correct
54 Correct 63 ms 2304 KB Output is correct
55 Correct 151 ms 7084 KB Output is correct
56 Correct 33 ms 1544 KB Output is correct
57 Correct 308 ms 14332 KB Output is correct
58 Correct 284 ms 14316 KB Output is correct
59 Correct 278 ms 14344 KB Output is correct
60 Correct 315 ms 14348 KB Output is correct
61 Correct 384 ms 14388 KB Output is correct
62 Correct 219 ms 9924 KB Output is correct
63 Correct 437 ms 14948 KB Output is correct
64 Correct 204 ms 9904 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 85 ms 9964 KB Output is correct
67 Correct 301 ms 14960 KB Output is correct
68 Correct 279 ms 14328 KB Output is correct
69 Correct 41 ms 1572 KB Output is correct
70 Correct 11 ms 596 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 64 ms 2180 KB Output is correct
73 Correct 14 ms 724 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 308 ms 14316 KB Output is correct
76 Correct 324 ms 14384 KB Output is correct
77 Correct 313 ms 14436 KB Output is correct
78 Correct 339 ms 14404 KB Output is correct
79 Correct 428 ms 14376 KB Output is correct
80 Correct 386 ms 14384 KB Output is correct
81 Correct 365 ms 12264 KB Output is correct
82 Correct 337 ms 12596 KB Output is correct