Submission #8169888


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define N 1000005
#define eps 1e-10
#define Pi acos(-1.0)
int n;
long long ans,m;
int a[N],b[N];
bool f[N];
char s[N];
inline bool C(LL x1)
{
	LL ret=0;
	for(int i=1;i<=n;i++)
	{
		LL x2=x1/b[n-i+1];
		if(a[i]>x2)
			ret+=a[i]-x2;
	}
	return ret<=m;
}
int main()
{
	scanf("%d%lld",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	LL l=-1,r=(LL)1e12+1;
	while(l+1<r)
	{
		LL mid=(l+r)/2;
		if(C(mid))
			r=mid;
		else
			l=mid;
	}
	printf("%lld",r);
}

Submission Info

Submission Time
Task E - Gluttony
User C20193620
Language C++14 (GCC 5.4.1)
Score 500
Code Size 642 Byte
Status AC
Exec Time 149 ms
Memory 6528 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:25:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld",&n,&m);
                       ^
./Main.cpp:27:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
                    ^
./Main.cpp:29:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&b[i]);
                    ^

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 38
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt
Case Name Status Exec Time Memory
sample_01.txt AC 2 ms 2304 KB
sample_02.txt AC 2 ms 2304 KB
sample_03.txt AC 2 ms 2304 KB
sub1_01.txt AC 130 ms 6528 KB
sub1_02.txt AC 4 ms 2304 KB
sub1_03.txt AC 48 ms 6528 KB
sub1_04.txt AC 12 ms 2304 KB
sub1_05.txt AC 68 ms 6528 KB
sub1_06.txt AC 88 ms 6528 KB
sub1_07.txt AC 3 ms 2304 KB
sub1_08.txt AC 121 ms 6528 KB
sub1_09.txt AC 44 ms 4480 KB
sub1_10.txt AC 73 ms 6528 KB
sub1_11.txt AC 94 ms 6528 KB
sub1_12.txt AC 41 ms 4480 KB
sub1_13.txt AC 20 ms 4480 KB
sub1_14.txt AC 66 ms 6528 KB
sub1_15.txt AC 53 ms 4480 KB
sub1_16.txt AC 84 ms 6528 KB
sub1_17.txt AC 68 ms 6528 KB
sub1_18.txt AC 129 ms 6528 KB
sub1_19.txt AC 129 ms 6528 KB
sub1_20.txt AC 129 ms 6528 KB
sub1_21.txt AC 129 ms 6528 KB
sub1_22.txt AC 129 ms 6528 KB
sub1_23.txt AC 129 ms 6528 KB
sub1_24.txt AC 127 ms 6528 KB
sub1_25.txt AC 129 ms 6528 KB
sub1_26.txt AC 149 ms 6528 KB
sub1_27.txt AC 149 ms 6528 KB
sub1_28.txt AC 149 ms 6528 KB
sub1_29.txt AC 149 ms 6528 KB
sub1_30.txt AC 149 ms 6528 KB
sub1_31.txt AC 149 ms 6528 KB
sub1_32.txt AC 149 ms 6528 KB
sub1_33.txt AC 149 ms 6528 KB
sub1_34.txt AC 3 ms 2304 KB
sub1_35.txt AC 71 ms 6528 KB