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. [洛谷P4779]【模板】单源最短路径(标准版)

    题目大意:单元最短路径(卡$SPFA$) 题解:$dijkstra$($\underline{\hspace{0.5em}}\underline{\hspace{0.5em}}gnu\underlin ...

  2. BZOJ1559 [JSOI2009]密码 【AC自动机 + 状压dp】

    题目链接 BZOJ1559 题解 考虑到这是一个包含子串的问题,而且子串非常少,我们考虑\(AC\)自动机上的状压\(dp\) 设\(f[i][j][s]\)表示长度为\(i\)的串,匹配到了\(AC ...

  3. POJ3294 Life Forms 【后缀数组】

    生命形式 时间限制: 5000MS   内存限制: 65536K 提交总数: 16660   接受: 4910 描述 你可能想知道为什么大多数外星人的生命形式与人类相似,不同的是表面特征,如身高,肤色 ...

  4. The XOR Largest Pair [Trie]

    描述 在给定的N个整数A1,A2--AN中选出两个进行xor运算,得到的结果最大是多少? 输入格式 第一行一个整数N,第二行N个整数A1-AN. 输出格式 一个整数表示答案. 样例输入 3 1 2 3 ...

  5. TSP问题之状压dp法

    首先,我们先来认识一下什么叫做TSP问题 旅行商问题,即TSP问题(Traveling Salesman Problem)又译为旅行推销员问题.货郎担问题,是数学领域中著名问题之一.假设有一个旅行商人 ...

  6. nginx+webpy+uswgi+jwplayer组合搭建流媒体服务器

    转载自:http://blog.csdn.net/cjsafty/article/details/7892392 目前,由于Flash的流行,网络上绝大多数的微视频网站都采用了Flv格式来播放视频. ...

  7. SVN 服务器安装及配置(WIN7)

    软件安装包 客户端: 服务端: 安装服务端 不整合 Apache 服务器可以忽略此选项. 安装程序会自动在path下配置好环境变量:D:\Subversion\bin; 查看是否安装成功: C:\Us ...

  8. Hadoop之yarn调用机制

    1,Mapper方法:如果在map方法之前执行一些程序用setup,之后用cleanup.同理在Reducer方法中也有setup和cleanup. 2,map任务是并行执行,没有谁先谁后,如果是两个 ...

  9. [bzoj2186][Sdoi2008]沙拉公主的困惑——数论

    题目大意 求 \[\sum_{i = 1}^{N!} [gcd(i, M!) = 1]\] 题解 显然,题目就是求 \[N!(1-\frac{1}{p_1})(1-\frac{1}{p_2})...\ ...

  10. JavaScript DOM编程艺术 读书笔记

    2. JavaScript语法 2.1 注释      HTML允许使用"<!--"注释跨越多个行,但JavaScript要求这种注释的每行都必须在开头加上"< ...