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 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的更多相关文章
- 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 ...
- 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...
- 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 ...
- 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 ...
- 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 ...
- 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(){ ...
- 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 = { ...
- 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 ...
- 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 ...
随机推荐
- Powershell使用真实的对象工作
Powershell使用真实的对象工作 来源 https://www.pstips.net/powershell-work-with-reallife-objects.html 每一个Powershe ...
- BZOJ1305 [CQOI2009]dance跳舞 【网络流】
1305: [CQOI2009]dance跳舞 Time Limit: 5 Sec Memory Limit: 162 MB Submit: 3714 Solved: 1572 [Submit][ ...
- 洛谷 P2218 [HAOI2007]覆盖问题 解题报告
P2218 [HAOI2007]覆盖问题 题目描述 某人在山上种了\(N\)棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄膜把这些小树遮盖起来,经过一番长久的思考,他 ...
- Extend the size of ext3 partition online in VM
1. Increase disk space in vCenter 2. scan disk on the Linux VM # fdisk -lu > /tmp/fdisk. # > / ...
- 【转载】深入理解PHP Opcode缓存原理
转载地址:深入理解PHP Opcode缓存原理 什么是opcode缓存? 当解释器完成对脚本代码的分析后,便将它们生成可以直接运行的中间代码,也称为操作码(Operate Code,opcode).O ...
- jquery教程-Jquery 获取标签个数 size()函数用法
jquery教程-Jquery 获取标签个数 size()函数用法,size() 方法返回被 jQuery 选择器匹配的元素的数量. 语法 $(selector).size() jQuery ...
- import as from import 区别
在python中import或者from…import是用来导入相应的模块.那每一种有什么具体的差别呢? 一.import 只有import,为最简单的引入对应的包.例如: import ...
- CTSC游记
CTSC游记 day 0 到达帝都. 复习板子 day 1 第一题傻逼题啊 第二题第三题写个暴力 好了120稳了 出来一看第一题基数排序炸了? 51+10+10崩盘 day 2 答辩有意思啊 王选怎么 ...
- 玩转Metasploit系列(第二集)
在上一节的内容中,大家了解了Metasploit的结构.这一节我们主要介绍的是msfconsole的理论. msfconsole理论 在MSF里面msfconsole可以说是最流行的一个接口程序.很多 ...
- Oracle 脚本记录
给表创建序列或触发器 create or replace procedure p_createseq(tablename in varchar2,key in varchar2) Authid Cur ...