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. odoo15里面密码与附件加密方式

    一.odoo里面用户设置的密码加密方式 加密是用[Passlib生成的PBKDF2 SHA512哈希] 加密后位数是128位 ` def _set_password(self): ctx = self ...

  2. odoo前端的Patch用法

    一.Patching code:根据官方功能解释 我们需要自定义 UI 的工作方式.一些受支持的 API 涵盖了许多常见需求. 例如,所有注册表都是很好的扩展点: 字段注册表允许添加/删除专门的字段组 ...

  3. win10系统 wsappx消耗内存导致死机

    问题描述:win10系统开机后,wsappx内存占用率一路飙升,直至电脑蓝屏,手动kill后,过一会死灰复燃. 问题解决:win+R输入 regedit 跳转注册表编辑器,找到 HKEY_LOCAL_ ...

  4. Java 验证电子邮箱是否合法

    工作中,常常遇到校验电子邮箱字符串是否符合规范的需求,这里提供如下两个基于正则表达式的校验方法: public static final String EMAIL_REGEX_DEFAULT = &q ...

  5. 代码随想录第11天 | 二叉树part01

      理论基础 需要了解 二叉树的种类,存储方式,遍历方式 以及二叉树的定义 文章讲解:https://programmercarl.com/%E4%BA%8C%E5%8F%89%E6%A0%91%E7 ...

  6. 【2020.11.24提高组模拟】变换 (transform) 题解

    [2020.11.24提高组模拟]变换 (transform) 题解 题意描述 给一个大小为\(n\)的\(01\)环\(A\),点编号为\(0,1,\dots,n-1\).每一个点\(i\)都与\( ...

  7. 「Log」2023.8.16 小记

    序幕 早上昏迷,九点才到校,少听了四道题,问题不大. 点咖啡喝. SAM 题也抽象.线段树合并,不会. 写个 AC 自动机板子. \(\color{royalblue}{P3808\ [模板]AC\ ...

  8. 微信小程序中supabase在线数据库使用指南

    在微信小程序中使用supabase在线数据库可以无需后端和服务器完成个人小项目的开发.本文记录我的使用过程,在阅读本文前,建议您先满足以下条件: 持有可用于开发的微信小程序 了解kexue上网 第一步 ...

  9. 实测提速 60%!Maven Daemon 全面加速 SeaTunnel 编译打包效率

    作者 | 张东浩 在大规模数据集成项目中,构建效率尤为关键.本文实测了 Apache SeaTunnel 项目在使用传统 Maven 与新一代构建工具 Maven Daemon(mvnd)下的打包效率 ...

  10. Spring Boot 集成 ShardingSphere-JDBC 配置示例

    概述 Apache ShardingSphere‐JDBC 旨在充分合理地在分布式的场景下利用关系型数据库的计算和存储能力,而并非实现一个全新的关系型数据库. 关系型数据库当今依然占有巨大市场份额,是 ...