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万册, ...
随机推荐
- 洛谷 P5019 铺设道路 & [NOIP2018提高组](贪心)
题目链接 https://www.luogu.org/problem/P5019 解题思路 一道典型的贪心题. 假设从左往右填坑,如果第i个深与第i+1个,那么第i+1个就不需要额外填: 如果第i+1 ...
- Linux常用命令操作文档
Ls命令:列出目录内容 选项 长选项 含义 -a --all 列出所有文件,包括隐藏的文件 -d --directory 指定一个目录 -F --classify 在每个列出的名字后面加上类型指示符( ...
- 73.Largest Rectangle in Histogram(最大矩形)
Level: Hard 题目描述: Given n non-negative integers representing the histogram's bar height where the ...
- StatusStrip 分类: C# 2015-07-23 11:58 2人阅读 评论(0) 收藏
通过StatusStrip显示窗体状态栏 同时将状态栏分成三部分 居左边显示相关文字信息 中间空白显示 居右边显示时间信息 1.创建窗体及添加StatusStrip 默认StatusStrip名称 ...
- C#设计模式:桥接模式(Bridge Pattern)
一,桥接模式,直接上代码 using System; using System.Collections.Generic; using System.Linq; using System.Text; u ...
- BUUCTF--新年快乐
测试文件:https://buuoj.cn/files/bbf9f68a97fd551edec384914d4f3fbe/93c43c5c-3d4d-4d17-a9a1-4ffb65ebb2fb.zi ...
- JavaScript —— 正则表达式元字符
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- BJSV-P-003高清智能卡口系统
高清智能卡口系统 捕获率99%,车牌识别率98% ■ 道路安装示意图 ■ 系统结构 ■ 抓拍实例 北京太速科技有限公司在线客服:QQ:448468544 淘宝网站:orihard.tao ...
- 一、表单和ajax中的post请求&&后台获取数据方法
一.表单和ajax中的post请求&&后台获取数据方法 最近要做后台数据接收,因为前台传来的数据太过于混乱,所以总结了一下前台数据post请求方法,顺便写了下相对应的后台接收方法. 前 ...
- Object.assign()遇到的问题分析
概念 Object.assign() 方法可以把任意多个的源对象自身的可枚举属性拷贝给目标对象,然后返回目标对象.语法如下: Object.assign(target, ...sources) Obj ...