Submission #743733

# Submission time Handle Problem Language Result Execution time Memory
743733 2023-05-17T20:02:29 Z MODDI Self Study (JOI22_ho_t2) C++14
62 / 100
383 ms 11428 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
ll m;
vi a, b;
bool check(ll atleast){
	ll use = 0;
	vl cur(n);
	for(int i = 0; i < n; i++){
		cur[i] = atleast;
		if(a[i] <= b[i]){
			use += m;
			continue;
		}
		ll here = min(m, (atleast-1) / a[i] + 1);
		use += m - here;
		cur[i] = max(0LL, atleast - here * a[i]);
	}
	for(int i = 0; i < n; i++){
		if(cur[i] == 0)	continue;
		ll here = (cur[i]-1)/b[i] + 1;
		use -= here;
		if(use < 0)	return false;
	}
	
	return use>=0;

}
int main(){
	cin>>n>>m;
	a.resize(n);
	b.resize(n);
	for(int i = 0; i < n; i++)	cin>>a[i];
	for(int i = 0; i < n; i++)	cin>>b[i];
	
	ll l = 0, r = 1e16, ans;
	while(l <= r){
		ll mid = l + (r - l) / 2;
		bool can = check(mid);
		if(can){
			ans = mid;
			l = mid + 1;
		}
		else
			r = mid - 1;
	}
	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 354 ms 10788 KB Output is correct
12 Correct 343 ms 11032 KB Output is correct
13 Correct 220 ms 8780 KB Output is correct
14 Correct 247 ms 8780 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 97 ms 6268 KB Output is correct
17 Correct 285 ms 11428 KB Output is correct
18 Correct 278 ms 10792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 97 ms 6268 KB Output is correct
3 Correct 285 ms 11428 KB Output is correct
4 Correct 278 ms 10792 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 284 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 304 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 136 ms 5532 KB Output is correct
14 Correct 96 ms 3788 KB Output is correct
15 Correct 68 ms 2924 KB Output is correct
16 Correct 59 ms 2324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 296 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 472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 354 ms 10788 KB Output is correct
12 Correct 343 ms 11032 KB Output is correct
13 Correct 220 ms 8780 KB Output is correct
14 Correct 247 ms 8780 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 284 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 136 ms 5532 KB Output is correct
24 Correct 96 ms 3788 KB Output is correct
25 Correct 68 ms 2924 KB Output is correct
26 Correct 59 ms 2324 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 296 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 472 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 97 ms 6268 KB Output is correct
36 Correct 285 ms 11428 KB Output is correct
37 Correct 278 ms 10792 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 296 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 300 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 300 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 6 ms 436 KB Output is correct
46 Correct 9 ms 608 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 60 ms 2076 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 ms 424 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 176 ms 5432 KB Output is correct
56 Correct 73 ms 3132 KB Output is correct
57 Correct 84 ms 3220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 284 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 304 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 136 ms 5532 KB Output is correct
10 Correct 96 ms 3788 KB Output is correct
11 Correct 68 ms 2924 KB Output is correct
12 Correct 59 ms 2324 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 296 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 472 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 97 ms 6268 KB Output is correct
22 Correct 285 ms 11428 KB Output is correct
23 Correct 278 ms 10792 KB Output is correct
24 Correct 57 ms 1836 KB Output is correct
25 Correct 151 ms 5064 KB Output is correct
26 Correct 31 ms 1364 KB Output is correct
27 Correct 266 ms 10796 KB Output is correct
28 Correct 276 ms 10776 KB Output is correct
29 Correct 283 ms 10784 KB Output is correct
30 Correct 300 ms 10780 KB Output is correct
31 Incorrect 383 ms 10796 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 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 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct
11 Correct 354 ms 10788 KB Output is correct
12 Correct 343 ms 11032 KB Output is correct
13 Correct 220 ms 8780 KB Output is correct
14 Correct 247 ms 8780 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 284 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 304 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 1 ms 300 KB Output is correct
23 Correct 136 ms 5532 KB Output is correct
24 Correct 96 ms 3788 KB Output is correct
25 Correct 68 ms 2924 KB Output is correct
26 Correct 59 ms 2324 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 296 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 472 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 296 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 300 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 300 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 6 ms 436 KB Output is correct
42 Correct 9 ms 608 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 60 ms 2076 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 ms 424 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 176 ms 5432 KB Output is correct
52 Correct 73 ms 3132 KB Output is correct
53 Correct 84 ms 3220 KB Output is correct
54 Correct 57 ms 1836 KB Output is correct
55 Correct 151 ms 5064 KB Output is correct
56 Correct 31 ms 1364 KB Output is correct
57 Correct 266 ms 10796 KB Output is correct
58 Correct 276 ms 10776 KB Output is correct
59 Correct 283 ms 10784 KB Output is correct
60 Correct 300 ms 10780 KB Output is correct
61 Incorrect 383 ms 10796 KB Output isn't correct
62 Halted 0 ms 0 KB -