King of Karaoke


Time Limit: 1 Second      Memory Limit: 65536 KB

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 , and the standard version of the song can be considered as another integer sequence . The score is the number of integers  satisfying  and .

As a good tuner, DreamGrid can choose an integer  (can be positive, 0, or negative) as his tune and add  to every element in . 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  (about 100), indicating the number of test cases. For each test case:

The first line contains one integer  (), indicating the length of the sequences  and .

The second line contains  integers  (), indicating the song performed by DreamGrid.

The third line contains  integers  (), indicating the standard version of the song.

It's guaranteed that at most 5 test cases have .

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  and changes  to .

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

原题地址:http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5753

题意:给你两个数组A,B,问你A数组所有元素同时加一个数或减一个数或不变之后与B数组相同的最大个数;

思路:因为数组A加的数是相同的所以A数组变化之后差值个数还是一样,所以直接计算A数组和B数组之间的差值最多的个数就行,因为可能有负数,所以用map又轻松又简单,map真是个好东西

代码:

#include<bits/stdc++.h>
using namespace std; int a[];
int b[];
int main()
{
std::ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
map<int,int>mp;
int n;
cin>>n;
for(int i=;i<n;i++){
cin>>a[i];
}
for(int i=;i<n;i++){
cin>>b[i];
}
for(int i=;i<n;i++){
mp[a[i]-b[i]]++;
}
int maxn=;
map<int,int>::iterator it;
for(it=mp.begin();it!=mp.end();it++){
if(it->second>maxn){
maxn=it->second;
}
}
cout<<maxn<<endl;
}
return ;
}

The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - B King of Karaoke的更多相关文章

  1. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

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

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

  3. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - M Lucky 7

    Lucky 7 Time Limit: 1 Second      Memory Limit: 65536 KB BaoBao has just found a positive integer se ...

  4. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - J CONTINUE...?

    CONTINUE...? Time Limit: 1 Second      Memory Limit: 65536 KB      Special Judge DreamGrid has  clas ...

  5. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple -A Peak

    Peak Time Limit: 1 Second      Memory Limit: 65536 KB A sequence of  integers  is called a peak, if ...

  6. ZOJ 4033 CONTINUE...?(The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple)

    #include <iostream> #include <algorithm> using namespace std; ; int a[maxn]; int main(){ ...

  7. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - F 贪心+二分

    Heap Partition Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge A sequence S = { ...

  8. The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - C 暴力 STL

    What Kind of Friends Are You? Time Limit: 1 Second      Memory Limit: 65536 KB Japari Park is a larg ...

  9. ZOJ 3962 E.Seven Segment Display / The 14th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple E.数位dp

    Seven Segment Display Time Limit: 1 Second      Memory Limit: 65536 KB A seven segment display, or s ...

随机推荐

  1. hdu 2199 Can you solve this equation? (二分法)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  2. BZOJ5323 [Jxoi2018]游戏 【数论/数学】

    题目链接 BZOJ5323 题解 有一些数是不能被别的数筛掉的 这些数出现最晚的位置就是该排列的\(t(p)\) 所以我们只需找出所有这些数,线性筛一下即可,设有\(m\)个 然后枚举最后的位置 \[ ...

  3. 洛谷 P3143 [USACO16OPEN]钻石收藏家Diamond Collector 解题报告

    P3143 [USACO16OPEN]钻石收藏家Diamond Collector 题目描述 Bessie the cow, always a fan of shiny objects, has ta ...

  4. eclipse关闭错误警告提示

  5. 迅雷Bolt图像拉伸不清晰的解决办法

    迅雷Bolt库中的图像拉伸的效果锯齿比较严重,常见的导致锯齿的情况: 1.在使用ImageObject时,drawmode为1拉伸模式下: 2.使用Bitmap类的Stretch函数拉伸图像: 虽然I ...

  6. JAVASCRIPT和JSP计算闰年

    0x01:JAVASCRIPT 实现 <h1 align="left">求闰年</h1> 开始年份: <input type="text&q ...

  7. Vue2.0关于生命周期和钩子函数

    Vue生命周期简介:   Vue1.0+和Vue2.0在生命周期钩子上的区别还是很大的,如下:   代码验证: <!DOCTYPE html> <html> <head& ...

  8. JavaScript中cookie使用

    转自:http://www.cnblogs.com/yjzhu/archive/2012/11/26/2789032.html 一.什么是 cookie? cookie 就是页面用来保存信息,比如自动 ...

  9. Spring - IoC(9): @Resoure & @Autowired

    @Resource 和 @Autowired 都是用来装配依赖的,它们之间有些异同. @Resoure @Resource 是 JSR-250 规范的注解. @Resource 可以标注在字段.方法上 ...

  10. bzoj4839 [Neerc2016]Abbreviation

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4839 [题解] pkusc怎么出bzoj原题啊 字符串随便处理一下就行了,大模拟 pkusc ...