Melody

题目描述

YellowStar is versatile. One day he writes a melody A = [A1, ..., AN ], and he has a standard melody B = [B1, ..., BN ]. YellowStar can split melody into several parts, it can be expressed as: K split position S = [S1, ..., SK], satisfy 1 ≤ S1 < S2 < · · · < SK = N. Melody A and B will be split into K parts:

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.

输入

Input is given from Standard Input in the following format:
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.

输出

Print one line denotes the minimal integer K .

样例输入

复制样例数据

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【签到水】的更多相关文章

  1. upc组队赛16 Winner Winner【位运算】

    Winner Winner 题目链接 题目描述 The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Tr ...

  2. upc组队赛16 GCDLCM 【Pollard_Rho大数质因数分解】

    GCDLCM 题目链接 题目描述 In FZU ACM team, BroterJ and Silchen are good friends, and they often play some int ...

  3. upc组队赛16 WTMGB【模拟】

    WTMGB 题目链接 题目描述 YellowStar is very happy that the FZU Code Carnival is about to begin except that he ...

  4. upc组队赛3 Chaarshanbegaan at Cafebazaar

    Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...

  5. upc组队赛3 Iranian ChamPions Cup

    Iranian ChamPions Cup 题目描述 The Iranian ChamPions Cup (ICPC), the most prestigious football league in ...

  6. upc组队赛14 Bus stop【签到水】

    Bus Stop 题目描述 In a rural village in Thailand, there is a long, straight, road with houses scattered ...

  7. upc组队赛6 Progressive Scramble【模拟】

    Progressive Scramble 题目描述 You are a member of a naive spy agency. For secure communication,members o ...

  8. upc组队赛1 过分的谜题【找规律】

    过分的谜题 题目描述 2060年是云南中医学院的百年校庆,于是学生会的同学们搞了一个连续猜谜活动:共有10个谜题,现在告诉所有人第一个谜题,每个谜题的答案就是下一个谜题的线索....成功破解最后一个谜 ...

  9. upc组队赛1 不存在的泳池【GCD】

    不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...

随机推荐

  1. Linux-第二篇常用命令

    1.常用目录文件操作命令 cd:切换目录 格式:cd 目录 ls:显示文件和目录列表.可选参数: -l 列出文件的详细信息 -a 列出当前目录所有文件,包含隐藏文件 ll:查看目录接口,相当于是ls ...

  2. 线程休眠只会用 Thread.sleep?来,教你新姿势!

    线程休眠是 Java 开发经常会用到的一个手段,就是让当前线程睡一会儿,睡醒之后再继续运行. 咱大多数程序员,多线程虽然学得不好,但线程休眠,无人不知,无人不晓,也都会用,不就是用 Thread.sl ...

  3. 爬虫之Js混淆&加密案例

    需求: 中国空气质量在线监测分析平台是一个收录全国各大城市天气数据的网站,包括温度.湿度.PM 2.5.AQI 等数据,链接为:https://www.aqistudy.cn/html/city_de ...

  4. mysql数据库操作指令汇总

    1.mysql -u root -p 登录数据库 2.表结构相同两表数据对拷 insert into A select * from B(插入全部字段数据)   insert into A(字段1.字 ...

  5. 用css画一个倒三角

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 机器学习-决策树算法+代码实现(基于R语言)

    分类树(决策树)是一种十分常用的分类方法.核心任务是把数据分类到可能的对应类别. 他是一种监管学习,所谓监管学习就是给定一堆样本,每个样本都有一组属性和一个类别,这些类别是事先确定的,通过学习得到一个 ...

  7. (转)yum的$releasever真是太反动了

    Posted on 2009年 10月9日 by JulyClyde 来看这篇文章的人,大都应该同意<Unix编程艺术>中提到的那些观点吧.今天就给大家看一个反例:yum 的 $relea ...

  8. 关于如何测试cpu性能的命令操作 linux系统

    for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/d ...

  9. ltp-ddt nand_ecc_tests

    NAND_S_FUNC_ECC_2K_BCH8_8ERRS_NO_OOB_ERR source "common.sh"; nandecc_tests.sh -r "0:0 ...

  10. Linux系统常用知识(centos7)

    一.查看系统版本 1.查看linux内核版本 #cat /etc/redhat-release 二.主机名 2.1定义: 静态的(Static hostname):“静态”主机名也称为内核主机名,是系 ...