D. Zero Quantity Maximization

194 篇文章 1 订阅
13 篇文章 0 订阅

链接:https://codeforces.com/problemset/problem/1133/D

You are given two arrays aa and bb, each contains nn integers.

You want to create a new array cc as follows: choose some real (i.e. not necessarily integer) number dd, and then for every i∈[1,n]i∈[1,n] let ci:=d⋅ai+bici:=d⋅ai+bi.

Your goal is to maximize the number of zeroes in array cc. What is the largest possible answer, if you choose dd optimally?

Input

The first line contains one integer nn (1≤n≤2⋅1051≤n≤2⋅105) — the number of elements in both arrays.

The second line contains nn integers a1a1, a2a2, ..., anan (−109≤ai≤109−109≤ai≤109).

The third line contains nn integers b1b1, b2b2, ..., bnbn (−109≤bi≤109−109≤bi≤109).

Output

Print one integer — the maximum number of zeroes in array cc, if you choose dd optimally.

Examples

input

Copy

5
1 2 3 4 5
2 4 7 11 3

output

Copy

2

input

Copy

3
13 37 39
1 2 3

output

Copy

2

input

Copy

4
0 0 0 0
1 2 3 4

output

Copy

0

input

Copy

3
1 2 -1
-6 -12 6

output

Copy

3

Note

In the first example, we may choose d=−2d=−2.

In the second example, we may choose d=−113d=−113.

In the third example, we cannot obtain any zero in array cc, no matter which dd we choose.

In the fourth example, we may choose d=6d=6.

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,l,r,k,s,d,ans,max1=0,mod=1e9+7;
long long b[500005],a[500005],dp[500005];
map<long double ,long long>m;
long double c[500005];
int main()
{
	cin>>n;
	d=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]==0&&a[i]==0)
		{
			d++;
		}
		else if(b[i]==0)
		{
			m[0.0]++;
		}
		else if(a[i]!=0)
		{
			c[i]=b[i]*1.0/a[i];
			m[c[i]]++;
		}
		max1=max(max1,m[c[i]]);
	}
	cout<<max1+d;
	
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值