Submission #857313

# Submission time Handle Problem Language Result Execution time Memory
857313 2023-10-05T21:00:16 Z StefanSebez Self Study (JOI22_ho_t2) C++14
62 / 100
335 ms 11604 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
signed main()
{
    int n,m;cin>>n>>m;
    int a[n+1],b[n+1],M=0;
    for(int i=1;i<=n;i++){cin>>a[i];M=max(M,a[i]*m);}
    for(int i=1;i<=n;i++){cin>>b[i];M=max(M,b[i]*m);}
    int l=1,r=M,mid=l+(r-l)/2,res;
    while(l<=r)
	{
		//printf("%lld %lld %lld: ",l,mid,r);
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			int x,z,k=inf;
			if(a[i]<=b[i])
			{
				x=0;
				z=(mid-x*(a[i]-b[i])+b[i]-1)/b[i];
				k=max(x,z);
			}
			else
			{
				x=mid/a[i];
				if(x>m) x=m;
				z=(mid-x*(a[i]-b[i])+b[i]-1)/b[i];
				k=min(k,max(x,z));
				x++;
				if(x>m) x=m;
				z=(mid-x*(a[i]-b[i])+b[i]-1)/b[i];
				k=min(k,max(x,z));
			}
			sum+=k;
			/*int k1=inf;
			for(int j=0;j<=m;j++)
			{
				int z=ceil((double)(mid-j*(a[i]-b[i]))/b[i]);
				k1=min(k1,max(j,z));
			}*/
			/*int x=0;
			if(a[i]>b[i])x=min(mid/(a[i]-b[i]),m);
			sum+=ceil((mid-x*(a[i]-b[i]))/b[i]);*/
			//cout<<"|"<<k<<" "<<k1<<"| ";
		}
		//cout<<endl;
		if(sum<=n*m)
		{
			res=mid;
			l=mid+1;
		}
		else r=mid-1;
		mid=l+(r-l)/2;
	}
	cout<<res<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 242 ms 10860 KB Output is correct
12 Correct 244 ms 10840 KB Output is correct
13 Correct 158 ms 8784 KB Output is correct
14 Correct 293 ms 8816 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 62 ms 6252 KB Output is correct
17 Correct 216 ms 11348 KB Output is correct
18 Correct 200 ms 10728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 62 ms 6252 KB Output is correct
3 Correct 216 ms 11348 KB Output is correct
4 Correct 200 ms 10728 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 108 ms 5420 KB Output is correct
14 Correct 68 ms 3664 KB Output is correct
15 Correct 51 ms 2844 KB Output is correct
16 Correct 41 ms 2352 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 432 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 4 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 242 ms 10860 KB Output is correct
12 Correct 244 ms 10840 KB Output is correct
13 Correct 158 ms 8784 KB Output is correct
14 Correct 293 ms 8816 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 108 ms 5420 KB Output is correct
24 Correct 68 ms 3664 KB Output is correct
25 Correct 51 ms 2844 KB Output is correct
26 Correct 41 ms 2352 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 432 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 62 ms 6252 KB Output is correct
36 Correct 216 ms 11348 KB Output is correct
37 Correct 200 ms 10728 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 5 ms 604 KB Output is correct
46 Correct 8 ms 740 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 42 ms 2140 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 5 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 122 ms 5540 KB Output is correct
56 Correct 55 ms 3252 KB Output is correct
57 Correct 103 ms 3244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 108 ms 5420 KB Output is correct
10 Correct 68 ms 3664 KB Output is correct
11 Correct 51 ms 2844 KB Output is correct
12 Correct 41 ms 2352 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 432 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 4 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 62 ms 6252 KB Output is correct
22 Correct 216 ms 11348 KB Output is correct
23 Correct 200 ms 10728 KB Output is correct
24 Correct 44 ms 1884 KB Output is correct
25 Correct 115 ms 5068 KB Output is correct
26 Correct 23 ms 1372 KB Output is correct
27 Correct 204 ms 10848 KB Output is correct
28 Correct 210 ms 10720 KB Output is correct
29 Correct 206 ms 10912 KB Output is correct
30 Correct 227 ms 10840 KB Output is correct
31 Correct 310 ms 10848 KB Output is correct
32 Correct 138 ms 6228 KB Output is correct
33 Correct 335 ms 11604 KB Output is correct
34 Incorrect 293 ms 6248 KB Output isn't correct
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 242 ms 10860 KB Output is correct
12 Correct 244 ms 10840 KB Output is correct
13 Correct 158 ms 8784 KB Output is correct
14 Correct 293 ms 8816 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 108 ms 5420 KB Output is correct
24 Correct 68 ms 3664 KB Output is correct
25 Correct 51 ms 2844 KB Output is correct
26 Correct 41 ms 2352 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 432 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 4 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 5 ms 604 KB Output is correct
42 Correct 8 ms 740 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 42 ms 2140 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 5 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 122 ms 5540 KB Output is correct
52 Correct 55 ms 3252 KB Output is correct
53 Correct 103 ms 3244 KB Output is correct
54 Correct 44 ms 1884 KB Output is correct
55 Correct 115 ms 5068 KB Output is correct
56 Correct 23 ms 1372 KB Output is correct
57 Correct 204 ms 10848 KB Output is correct
58 Correct 210 ms 10720 KB Output is correct
59 Correct 206 ms 10912 KB Output is correct
60 Correct 227 ms 10840 KB Output is correct
61 Correct 310 ms 10848 KB Output is correct
62 Correct 138 ms 6228 KB Output is correct
63 Correct 335 ms 11604 KB Output is correct
64 Incorrect 293 ms 6248 KB Output isn't correct
65 Halted 0 ms 0 KB -