King of Karaoke ZOJ - 4025
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的更多相关文章
- 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 ...
- King of Karaoke
King of Karaoke Time Limit: 1 Second Memory Limit: 65536 KB It's Karaoke time! DreamGrid is performi ...
- [ZOJ 4025] King of Karaoke
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5766 求两个序列的相对元素的差出现次数最多的,最低出现一次. AC代 ...
- The 15th Zhejiang Provincial Collegiate Programming Contest(部分题解)
ZOJ 4024 Peak 题意 给出n和n个数,判断该数列是否是凸形的. 解题思路 从前往后第一对逆序数,和从后往前第一队逆序数,如果都非零而且相邻,证明该数组是凸形的. 代码 #include & ...
- 2018浙江省赛(ACM) The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple
我是铁牌选手 这次比赛非常得爆炸,可以说体验极差,是这辈子自己最脑残的事情之一. 天时,地利,人和一样没有,而且自己早早地就想好了甩锅的套路. 按理说不开K就不会这么惨了啊,而且自己也是毒,不知道段错 ...
- ZOJ 2334 Monkey King
并查集+左偏树.....合并的时候用左偏树,合并结束后吧父结点全部定成树的根节点,保证任意两个猴子都可以通过Find找到最厉害的猴子 Monkey King ...
- zoj 2334 Monkey King/左偏树+并查集
原题链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1389 大致题意:N只相互不认识的猴子(每只猴子有一个战斗力值) 两只 ...
- ZOJ 2334 HDU 1512 Monkey King
题意: 猴子们打架 认识的猴子不会打架 两仅仅猴子打完以后就认识了 A认识B B认识C A也认识C 每次打架由两伙猴子进行 分别选出自己的最高战斗力 在战斗之后两仅仅猴子战斗力减半 给出 ...
- King's Quest —— POJ1904(ZOJ2470)Tarjan缩点
King's Quest Time Limit: 15000MS Memory Limit: 65536K Case Time Limit: 2000MS Description Once upon ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
随机推荐
- 简单介绍List和数组转List集合
目录 综述 如何创建List 六种数组转List的方法 for循环遍历 Arrays.asList() new ArrayList<>(Arrays.asList(array)) Coll ...
- win10将python打包成apk详细文档
打包不支持windows所以可以找一台linux的电脑 或者用win10子系统(推荐) 我用的是Ubuntu 方法:https://www.jianshu.com/p/fcf21d45ea74 我简单 ...
- 校内NOI模拟测试007T1 送分(score) “简单”的计数
问题描述 校内评测链接 良心出题人准备为大家送出大量的分数. 出题人生成了一个序列,其中第\(\)个元素为\(a_i\). 定义一个集合\(\)的分值为 \[F(S,x) = \sum_{T \sub ...
- FastAPI权限迷宫:RBAC与多层级依赖的魔法通关秘籍
title: FastAPI权限迷宫:RBAC与多层级依赖的魔法通关秘籍 date: 2025/06/04 21:17:50 updated: 2025/06/04 21:17:50 author: ...
- 「Log」2023.8.14 小记
序幕 起晚了,七点半到校. 跟化竞选手寒暄几句之后就去开电脑. 补周末没写的博客,补落下的题单. 学杜教筛??????不会卷积????? 暂时放弃,学一下扩欧. 写了篇扩欧博客. \(\text{Li ...
- 安卓手机上部署nodejs服务器
一.准备软件 Termux 下载地址: 链接:https://pan.baidu.com/s/1J3OQITWc34uT-Mc8B-moPA?pwd=ug9j 提取码:ug9j KSW ...
- 数栈产品分享:基于StreamWorks构建实时大数据处理平台
数栈是云原生-站式数据中台PaaS,我们在github和gitee上有一个有趣的开源项目:FlinkX,FlinkX是一个基于Flink的批流统一的数据同步工具,既可以采集静态的数据,也可以采集实时变 ...
- 如何在FastAPI中打造坚不可摧的安全防线?
title: 如何在FastAPI中打造坚不可摧的安全防线? date: 2025/06/20 11:33:15 updated: 2025/06/20 11:33:15 author: cmdrag ...
- 十二、buildroot系统 adb登录权限设置
4.6.4.adb权限设置 android-adbd 是 ADB(Android Debug Bridge)的守护进程,允许开发者远程访问和调试设备.它通常用于 Android 设备,但在嵌入式 ...
- Nuclear - 基于流媒体的隐私优先音乐播放器
Nuclear - 基于流媒体的隐私优先音乐播放器 项目描述 Nuclear是一款专注于从免费来源流媒体播放音乐的桌面应用,具有以下核心特点: 隐私优先设计,不进行用户追踪或数据分析 无广告干扰的纯净 ...