upc组队赛16 Melody【签到水】
Melody
题目描述
Two parts of melody are equal while the change of tone is consistent. It can be expressed as:
A = [A1, ..., AM ] equal to B = [B1, ..., BM ] need to satisfy:
Now YellowStar wants each part of his melody A equals to each part of standard melody B. In other words, the following conditions need to be met:
YellowStar also wants the number K of split parts as minimum as possible.
输入
N
A1 A2 . . . AN
B1 B2 . . . BN
Constraints
1 ≤ N ≤ 105
1 ≤ Ai, Bi ≤ 109
All Ai are distinct and all Bi are distinct.
All inputs are integers.
输出
样例输入
复制样例数据
5
1 3 2 4 5
4 9 10 11 8
样例输出
3
题解
枚举找单调性不同的位置个数
代码
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define sca(x) scanf("%d",&x)
#define sca2(x,y) scanf("%d%d",&x,&y)
#define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
inline ll read(){ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;}
#define read read()
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define MOD 998244353
#define mod 1e9+7
#define N 1000005
const int maxn=;
ll a[maxn];
ll b[maxn];
int main()
{
int n;
sca(n);
rep(i,,n)
scl(a[i]);
rep(i,,n)
scl(b[i]);
ll k = ;
rep(i,,n)
{
if((LL)(a[i]-a[i-])*(LL)(b[i]-b[i-]) > )
continue;
else
k++;
}
prl(k+);
}
upc组队赛16 Melody【签到水】的更多相关文章
- upc组队赛16 Winner Winner【位运算】
Winner Winner 题目链接 题目描述 The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Tr ...
- upc组队赛16 GCDLCM 【Pollard_Rho大数质因数分解】
GCDLCM 题目链接 题目描述 In FZU ACM team, BroterJ and Silchen are good friends, and they often play some int ...
- upc组队赛16 WTMGB【模拟】
WTMGB 题目链接 题目描述 YellowStar is very happy that the FZU Code Carnival is about to begin except that he ...
- upc组队赛3 Chaarshanbegaan at Cafebazaar
Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...
- upc组队赛3 Iranian ChamPions Cup
Iranian ChamPions Cup 题目描述 The Iranian ChamPions Cup (ICPC), the most prestigious football league in ...
- upc组队赛14 Bus stop【签到水】
Bus Stop 题目描述 In a rural village in Thailand, there is a long, straight, road with houses scattered ...
- upc组队赛6 Progressive Scramble【模拟】
Progressive Scramble 题目描述 You are a member of a naive spy agency. For secure communication,members o ...
- upc组队赛1 过分的谜题【找规律】
过分的谜题 题目描述 2060年是云南中医学院的百年校庆,于是学生会的同学们搞了一个连续猜谜活动:共有10个谜题,现在告诉所有人第一个谜题,每个谜题的答案就是下一个谜题的线索....成功破解最后一个谜 ...
- upc组队赛1 不存在的泳池【GCD】
不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...
随机推荐
- 这样设计 Java 异常更优雅,赶紧学!
来源:lrwinx.github.io/2016/04/28/如何优雅的设计java异常/ 导语 异常处理是程序开发中必不可少操作之一,但如何正确优雅的对异常进行处理确是一门学问,笔者根据自己的开发经 ...
- BFS+打印路径
题目是给你起点sx,和终点gx:牛在起点可以进行下面两个操作: 步行:John花一分钟由任意点X移动到点X-1或点X+1. 瞬移:John花一分钟由任意点X移动到点2*X. 你要输出最短步数及打印路径 ...
- II play with GG
https://ac.nowcoder.com/acm/contest/338/I 题解:首先轮到出手的时候如果在(0,0)上肯定是输的,而(0,1)(1,0)(0,2)(2,0)(1,1)肯定是赢的 ...
- Python之获取文件夹中文件列表以及glob与fnmatch模块的使用
获取文件夹中的文件列表 print(os.listdir("../secondPackage")) # ['__init__.py', 'secondCookBook.py', ' ...
- PHP-不涉及第三个变量交换两个变量的值
不涉及第三个变量交换两个变量的值 方法1:使用加减法 <?php $a = 1; $b = 2; $a = $a+$b; $b = $a-$b; $a = $a-$b; printf(" ...
- python 面向对象(类)--学习笔记
面向对象是一种编程方式, 主要集中在类和对象的两个概念 python 中的类符合封装, 继承, 多态的特征 类 是一个模板, 是n多函数的集成 对象 是类的实例化 类的成员分为三大类:字段.方法.属性 ...
- MyEclipse创建maven项目时报: org.apache.maven.archiver.MavenArchiver.getManifest 错误
创建项目报错,如图: 原因就是maven的配置文件不是最新的,MyEclipse2014解决方法: 1.help ->Install New sitie... 2.点击add 3.填写name和 ...
- qt opencv 视频分析
脱岗 越线 qimage qpixmap opencv 回调视频采集
- TP、FP、FN、TN的含义
true positive(被正确分类的正例) false negative(本来是正例,错分为负例) true negative(被正确分类的负例) false positive(本来是负例,被错分 ...
- 运行rabbitmq
docker run -d -p 5672:5672 -p 15672:15672 --name myrabbitmq c4663bdca2cd