Submission #551448

# Submission time Handle Problem Language Result Execution time Memory
551448 2022-04-20T17:45:58 Z luka1234 Self Study (JOI22_ho_t2) C++14
62 / 100
412 ms 11604 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
ll n,m;
ll a[300001],b[300001];
bool check(ll f){
	ll raod=n*m;
	vector<ll> v;
	ll cnt=0;
	for(ll k=1;k<=n;k++){
		if(b[k]>=a[k]){
			cnt=f/b[k];
			if(f%b[k]!=0)
			   cnt++;
			if(cnt>raod)
			   return 0;
			raod-=cnt;
		}
		else{
			v.push_back(k);
		}
	}
	ll dar=0;
	for(ll ind:v){
		ll i=a[ind];
		ll j=b[ind];
		cnt=f/i;
		if(f%i!=0)
		   cnt++;
		if(cnt>m)
		   cnt=m;
		if(raod<cnt)
		   return 0;
		raod-=cnt;
		dar=f-cnt*i;
		if(dar<=0)
		   continue;
		cnt=dar/j;
		if(dar%j!=0)
		   cnt++;
		if(raod<cnt)
		   return 0;
		raod-=cnt;
	}
	if(raod<0)
	   return 0;
	else
	   return 1;
}
int main(){
	cin>>n>>m;
	for(ll k=1;k<=n;k++){
		cin>>a[k];
	}
	for(ll k=1;k<=n;k++){
		cin>>b[k];
	}
	ll l=0,r=3e14;
	ll md;
	bool bl;
	while(l<r){
		md=(l+r+1)/2;
		bl=check(md);
		if(bl==1){
			l=md;
		}
		else{
			r=md-1;
		}
	}
	cout<<l;
    return 0;
}
# 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 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 404 ms 8248 KB Output is correct
12 Correct 388 ms 8288 KB Output is correct
13 Correct 249 ms 4868 KB Output is correct
14 Correct 412 ms 11604 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 101 ms 4932 KB Output is correct
17 Correct 324 ms 4964 KB Output is correct
18 Correct 286 ms 4972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 101 ms 4932 KB Output is correct
3 Correct 324 ms 4964 KB Output is correct
4 Correct 286 ms 4972 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 1 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 1 ms 212 KB Output is correct
13 Correct 141 ms 2568 KB Output is correct
14 Correct 89 ms 1852 KB Output is correct
15 Correct 72 ms 1452 KB Output is correct
16 Correct 62 ms 1184 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 2 ms 340 KB Output is correct
23 Correct 6 ms 340 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 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 404 ms 8248 KB Output is correct
12 Correct 388 ms 8288 KB Output is correct
13 Correct 249 ms 4868 KB Output is correct
14 Correct 412 ms 11604 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 1 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 1 ms 212 KB Output is correct
23 Correct 141 ms 2568 KB Output is correct
24 Correct 89 ms 1852 KB Output is correct
25 Correct 72 ms 1452 KB Output is correct
26 Correct 62 ms 1184 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 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 101 ms 4932 KB Output is correct
36 Correct 324 ms 4964 KB Output is correct
37 Correct 286 ms 4972 KB Output is correct
38 Correct 1 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 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 8 ms 360 KB Output is correct
46 Correct 13 ms 496 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 61 ms 1672 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 340 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 200 ms 4244 KB Output is correct
56 Correct 76 ms 1852 KB Output is correct
57 Correct 111 ms 3744 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 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 141 ms 2568 KB Output is correct
10 Correct 89 ms 1852 KB Output is correct
11 Correct 72 ms 1452 KB Output is correct
12 Correct 62 ms 1184 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 0 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 101 ms 4932 KB Output is correct
22 Correct 324 ms 4964 KB Output is correct
23 Correct 286 ms 4972 KB Output is correct
24 Incorrect 56 ms 1012 KB Output isn't correct
25 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
5 Correct 0 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 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 404 ms 8248 KB Output is correct
12 Correct 388 ms 8288 KB Output is correct
13 Correct 249 ms 4868 KB Output is correct
14 Correct 412 ms 11604 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 1 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 1 ms 212 KB Output is correct
23 Correct 141 ms 2568 KB Output is correct
24 Correct 89 ms 1852 KB Output is correct
25 Correct 72 ms 1452 KB Output is correct
26 Correct 62 ms 1184 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 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 1 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 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 8 ms 360 KB Output is correct
42 Correct 13 ms 496 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 61 ms 1672 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 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 200 ms 4244 KB Output is correct
52 Correct 76 ms 1852 KB Output is correct
53 Correct 111 ms 3744 KB Output is correct
54 Incorrect 56 ms 1012 KB Output isn't correct
55 Halted 0 ms 0 KB -