답안 #857316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857316 2023-10-05T21:03:51 Z StefanSebez Self Study (JOI22_ho_t2) C++14
0 / 100
749 ms 5104 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];
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    int l=1,r=inf,mid=l+(r-l)/2,res=0;
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 356 ms 4956 KB Output is correct
12 Correct 368 ms 5104 KB Output is correct
13 Correct 214 ms 5100 KB Output is correct
14 Incorrect 749 ms 5096 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 129 ms 2848 KB Output is correct
10 Correct 86 ms 1964 KB Output is correct
11 Correct 65 ms 1580 KB Output is correct
12 Correct 52 ms 1116 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 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 Incorrect 5 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 356 ms 4956 KB Output is correct
12 Correct 368 ms 5104 KB Output is correct
13 Correct 214 ms 5100 KB Output is correct
14 Incorrect 749 ms 5096 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 129 ms 2848 KB Output is correct
10 Correct 86 ms 1964 KB Output is correct
11 Correct 65 ms 1580 KB Output is correct
12 Correct 52 ms 1116 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 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 Incorrect 5 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 356 ms 4956 KB Output is correct
12 Correct 368 ms 5104 KB Output is correct
13 Correct 214 ms 5100 KB Output is correct
14 Incorrect 749 ms 5096 KB Output isn't correct
15 Halted 0 ms 0 KB -