博客
关于我
C - Zero Quantity Maximization
阅读量:244 次
发布时间:2019-03-01

本文共 1765 字,大约阅读时间需要 5 分钟。

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.ExamplesInput

51 2 3 4 52 4 7 11 3

Output

2

Input

313 37 391 2 3

Output

2

Input

40 0 0 01 2 3 4

Output

0

Input

31 2 -1-6 -12 6

Output

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.


思路:统计一下变成0的d最多的是哪个,注意下都是0的时候额外加,这题好像要longdouble 的精度

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const int maxn=2e5+1000;typedef long long LL;LL a[maxn],b[maxn];int main(void){// cin.tie(0);std::ios::sync_with_stdio(false); map
map1; LL n;cin>>n; LL sum=0;LL cnt=0; for(LL i=1;i<=n;i++) cin>>a[i]; for(LL i=1;i<=n;i++) cin>>b[i]; for(LL i=1;i<=n;i++){ if(a[i]!=0){ long double c=(-1*1.0)*b[i]/a[i]; //似乎要long double map1[c]++; } if(a[i]==0&&b[i]==0) cnt++;//注意是额外加的..不是直接放sum } for(map
::iterator it=map1.begin();it!=map1.end();it++){ sum=max(sum,it->second); } cout<
<

转载地址:http://pldt.baihongyu.com/

你可能感兴趣的文章
mysql 多个表关联查询查询时间长的问题
查看>>
mySQL 多个表求多个count
查看>>
mysql 多字段删除重复数据,保留最小id数据
查看>>
MySQL 多表联合查询:UNION 和 JOIN 分析
查看>>
MySQL 大数据量快速插入方法和语句优化
查看>>
mysql 如何给SQL添加索引
查看>>
mysql 字段区分大小写
查看>>
mysql 字段合并问题(group_concat)
查看>>
mysql 字段类型类型
查看>>
MySQL 字符串截取函数,字段截取,字符串截取
查看>>
MySQL 存储引擎
查看>>
mysql 存储过程 注入_mysql 视图 事务 存储过程 SQL注入
查看>>
MySQL 存储过程参数:in、out、inout
查看>>
mysql 存储过程每隔一段时间执行一次
查看>>
mysql 存在update不存在insert
查看>>
Mysql 学习总结(86)—— Mysql 的 JSON 数据类型正确使用姿势
查看>>
Mysql 学习总结(87)—— Mysql 执行计划(Explain)再总结
查看>>
Mysql 学习总结(88)—— Mysql 官方为什么不推荐用雪花 id 和 uuid 做 MySQL 主键
查看>>
Mysql 学习总结(89)—— Mysql 库表容量统计
查看>>
mysql 实现主从复制/主从同步
查看>>