https://vjudge.net/problem/ZOJ-4025/origin

https://vjudge.net/contest/399385#problem/B

It's Karaoke time! DreamGrid is performing the song Powder Snow in the game King of Karaoke. The song performed by DreamGrid can be considered as an integer sequence $D_1, D_2, \dots, D_n$, and the standard version of the song can be considered as another integer sequence $S_1, S_2, \dots, S_n$. The score is the number of integers $i$ satisfying $1 \le i \le n$ and $S_i = D_i$.

As a good tuner, DreamGrid can choose an integer $K$ (can be positive, 0, or negative) as his tune and add $K$ to every element in $D$. Can you help him maximize his score by choosing a proper tune?

Input

There are multiple test cases. The first line of the input contains an integer $T$ (about 100), indicating the number of test cases. For each test case:

The first line contains one integer $n$ ($1 \le n \le 10^5$), indicating the length of the sequences $D$ and $S$.

The second line contains $n$ integers $D_1, D_2, \dots, D_n$ ($-10^5 \le D_i \le 10^5$), indicating the song performed by DreamGrid.

The third line contains $n$ integers $S_1, S_2, \dots, S_n$ ($-10^5 \le S_i \le 10^5$), indicating the standard version of the song.

It's guaranteed that at most 5 test cases have $n > 100$.

Output

For each test case output one line containing one integer, indicating the maximum possible score.

Sample Input

2
4
1 2 3 4
2 3 4 6
5
-5 -4 -3 -2 -1
5 4 3 2 1

Sample Output

3
1

Hint

For the first sample test case, DreamGrid can choose $K = 1$ and changes $D$ to $\{2,3,4,5\}$.

For the second sample test case, no matter which $K$ DreamGrid chooses, he can only get at most 1 match.

#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
using namespace std; int S[100005] = {0};
int D[100005] = {0};
int sub[400005] = {0};
int main()
{
int T = 0;
cin >> T;
while(T--)
{
int n = 0;
cin >> n;
for(int i = 0;i<=400000;i++)
{
sub[i] = 0;
} for(int i = 0;i<n;i++)
{
cin >> D[i];
}
for(int i = 0;i<n;i++)
{
cin >> S[i];
}
for(int i = 0;i<n;i++)
{
int SUB = D[i] - S[i];
sub[SUB + 200000] += 1;
}
int maxp = 0;
int max = sub[0];
for(int i = 0;i <= 400000;i++)
{
if(sub[i] > max)
{
maxp = i;
max = sub[i];
}
}
cout << max << endl;
}
return 0;
}

  

King of Karaoke ZOJ - 4025的更多相关文章

  1. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - B King of Karaoke

    King of Karaoke Time Limit: 1 Second      Memory Limit: 65536 KB It's Karaoke time! DreamGrid is per ...

  2. King of Karaoke

    King of Karaoke Time Limit: 1 Second Memory Limit: 65536 KB It's Karaoke time! DreamGrid is performi ...

  3. [ZOJ 4025] King of Karaoke

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5766 求两个序列的相对元素的差出现次数最多的,最低出现一次. AC代 ...

  4. The 15th Zhejiang Provincial Collegiate Programming Contest(部分题解)

    ZOJ 4024 Peak 题意 给出n和n个数,判断该数列是否是凸形的. 解题思路 从前往后第一对逆序数,和从后往前第一队逆序数,如果都非零而且相邻,证明该数组是凸形的. 代码 #include & ...

  5. 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple

    我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...

  6. ZOJ 2334 Monkey King

    并查集+左偏树.....合并的时候用左偏树,合并结束后吧父结点全部定成树的根节点,保证任意两个猴子都可以通过Find找到最厉害的猴子                       Monkey King ...

  7. zoj 2334 Monkey King/左偏树+并查集

    原题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1389 大致题意:N只相互不认识的猴子(每只猴子有一个战斗力值) 两只 ...

  8. ZOJ 2334 HDU 1512 Monkey King

    题意: 猴子们打架  认识的猴子不会打架  两仅仅猴子打完以后就认识了  A认识B B认识C A也认识C  每次打架由两伙猴子进行  分别选出自己的最高战斗力  在战斗之后两仅仅猴子战斗力减半  给出 ...

  9. King's Quest —— POJ1904(ZOJ2470)Tarjan缩点

    King's Quest Time Limit: 15000MS Memory Limit: 65536K Case Time Limit: 2000MS Description Once upon ...

  10. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

随机推荐

  1. 在Ubuntu上使用Let's Encrypt配置Nginx SSL证书并自动更新

    在Ubuntu上使用Let's Encrypt配置Nginx SSL证书并自动更新 绪言 这篇文章其实内容不多,难度不大,只是自己记录一下. Arisu拷打了我几次我在阿里云上花钱购买SSL证书一事. ...

  2. LLaMA (以LLaMA2为例,文末附加对比1 2 3 三个版本的变化)

    补充背景: 关于Transformer和Llama架构的演进 一.背景 LLaMA 2 和 LLaMA2-Chat 参数规模:70亿.130亿和700亿 数据和训练规模: 上下文长度 训练资源 性能表 ...

  3. 详解鸿蒙Next仓颉开发语言中的全屏模式

    大家好,今天跟大家分享一下仓颉开发语言中的全屏模式. 和ArkTS一样,仓颉的新建项目默认是非全屏模式的,如果你的应用颜色比较丰富,就会发现屏幕上方和底部的留白,这是应用自动避让了屏幕上方摄像头区域和 ...

  4. Java 通用对象数值比较方法

    前言 请各大网友尊重本人原创知识分享,谨记本人博客:南国以南i. 提示:以下是本篇文章正文内容,下面案例可供参考 说明 主要用于比较两个对象是否相等,特别处理了数值类型的比较(包括字符串形式的数值) ...

  5. windows10搭建gitlab服务器

    gitlab服务器没有win运行环境,所以需要先搭建个虚拟机:windows10+VMware(Centos7) +gitlab+局域网其他电脑访问 一:VMware 安装,网上找找有安装教程 二:虚 ...

  6. type和interface与namespace和module

    type 和 interface 的区别 type 可以定义基本类型 也可以定义对象.数组.函数等 // 1. 定义基本类型 type StudentNameType = string; const ...

  7. 【8*】Slope Trick 学习笔记

    前言 从 一些快速笔记 中分离出来的,因为这一知识点写的内容太多了,可以拿出来专门开一篇学习笔记. Slope Trick 不是斜率优化!Slope Trick 不是斜率优化!Slope Trick ...

  8. Codeforces Round #563 (Div. 2) ABCD 题解

    A. Ehab Fails to Be Thanos 题意:问你能否对a数组任意排序,使得前n段和不等于后n段和. 思路:水题,直接从小到大排序.这个情况都相等就一定无解. view code #in ...

  9. jz2440 环境搭建

    2.搭建三者互通 1.搭建TFTP服务 这两点搞定基本可以飞奔了 记录一下 配置 板子的ip ifconfig eth3 IP地址 不用重启network服务因为也没有这个服务 当然虚拟机里面的一样 ...

  10. spring 中 mapper 中 resultMap resultType

    简介 一般 resultMap 适用于自定义类型 resultType 适用于java自带的类型