http://codeforces.com/problemset/problem/950/B

Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.

Zhorik knows that each of the messages is an archive containing one or more files. Zhorik knows how each of these archives was transferred through the network: if an archive consists of k files of sizes l1, l2, ..., lk bytes, then the i-th file is split to one or more blocks bi, 1, bi, 2, ..., bi, mi (here the total length of the blocks bi, 1 + bi, 2 + ... + bi, mi is equal to the length of the file li), and after that all blocks are transferred through the network, maintaining the order of files in the archive.

Zhorik thinks that the two messages contain the same archive, because their total lengths are equal. However, each file can be split in blocks in different ways in the two messages.

You are given the lengths of blocks in each of the two messages. Help Zhorik to determine what is the maximum number of files could be in the archive, if the Zhorik's assumption is correct.

Input

The first line contains two integers nm (1 ≤ n, m ≤ 105) — the number of blocks in the first and in the second messages.

The second line contains n integers x1, x2, ..., xn (1 ≤ xi ≤ 106) — the length of the blocks that form the first message.

The third line contains m integers y1, y2, ..., ym (1 ≤ yi ≤ 106) — the length of the blocks that form the second message.

It is guaranteed that x1 + ... + xn = y1 + ... + ym. Also, it is guaranteed that x1 + ... + xn ≤ 106.

Output

Print the maximum number of files the intercepted array could consist of.

Examples
input

Copy
7 6
2 5 3 1 11 4 4
7 8 2 4 1 8
output
3
input

Copy
3 3
1 10 100
1 100 10
output
2
input

Copy
1 4
4
1 1 1 1
output
1
Note

In the first example the maximum number of files in the archive is 3. For example, it is possible that in the archive are three files of sizes 2 + 5 = 7, 15 = 3 + 1 + 11 = 8 + 2 + 4 + 1 and 4 + 4 = 8.

In the second example it is possible that the archive contains two files of sizes 1 and 110 = 10 + 100 = 100 + 10. Note that the order of files is kept while transferring archives through the network, so we can't say that there are three files of sizes 1, 10 and 100.

In the third example the only possibility is that the archive contains a single file of size 4.

// 去吧!皮卡丘! 把AC带回来!
// へ     /|
//   /\7    ∠_/
//   / │   / /
//  │ Z _,< /   /`ヽ
//  │     ヽ   /  〉
//  Y     `  /  /
//  イ● 、 ●  ⊂⊃〈  /
//  ()  へ    | \〈
//   >ー 、_  ィ  │ //
//   / へ   / ノ<| \\
//   ヽ_ノ  (_/  │//
//    7       |/
//    >―r ̄ ̄`ー―_
//**************************************
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define ri register int
template <class T> inline T min(T a, T b, T c) { return min(min(a, b), c); }
template <class T> inline T max(T a, T b, T c) { return max(max(a, b), c); }
template <class T> inline T min(T a, T b, T c, T d) {
return min(min(a, b), min(c, d));
}
template <class T> inline T max(T a, T b, T c, T d) {
return max(max(a, b), max(c, d));
}
#define scanf1(x) scanf("%d", &x)
#define scanf2(x, y) scanf("%d%d", &x, &y)
#define scanf3(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define scanf4(x, y, z, X) scanf("%d%d%d%d", &x, &y, &z, &X)
#define pi acos(-1)
#define me(x, y) memset(x, y, sizeof(x));
#define For(i, a, b) for (int i = a; i <= b; i++)
#define FFor(i, a, b) for (int i = a; i >= b; i--)
#define bug printf("***********\n");
#define mp make_pair
#define pb push_back
const int maxn = 1e8 + ;
const int maxx = 1e6 + ;
// name*******************************
bool vis[maxn];
int sum=;
int n,m;
int x;
int ans=;
// function****************************** //***************************************
int main() {
// ios::sync_with_stdio(0); cin.tie(0);
// freopen("test.txt", "r", stdin);
// freopen("outout.txt","w",stdout);
cin>>n>>m;
For(i,,n)
{
cin>>x;
sum+=x;
vis[sum]=;
}
sum=;
For(i,,m){
cin>>x;
sum+=x;
if(vis[sum])ans++;
}
cout<<ans; return ;
}

469 B. Intercepted Message的更多相关文章

  1. [CF] 950B Intercepted Message

    B. Intercepted Message time limit per test1 second memory limit per test512 megabytes inputstandard ...

  2. 题解 CF950B 【Intercepted Message】

    题目链接 先吐槽一番:本宝宝好久没写过题解了...首先我们想一个贪心策咯.就是我们预处理出前缀和,然后一边扫过去,记录一个l1,l2和一个n1,n2.分别表示我们现在第一个数组切到l1,上一次切是在n ...

  3. 【codeforces】【比赛题解】#950 CF Round #469 (Div. 2)

    剧毒比赛,至少涨了分对吧.: ( [A]Left-handers, Right-handers and Ambidexters 题意: 有\(l\)个右撇子,\(r\)个左撇子,\(a\)个双手都惯用 ...

  4. Codeforces Round #469 Div. 2 A B C D E

    A. Left-handers, Right-handers and Ambidexters 题意 \(l\)个左撇子,\(r\)个右撇子,\(a\)个两手均可.要组成一支队伍,里面用左手的人数与用右 ...

  5. Codeforces Round #469 Div. 2题解

    A. Left-handers, Right-handers and Ambidexters time limit per test 1 second memory limit per test 25 ...

  6. ACM 第七天

    水题 B - Minimum’s Revenge There is a graph of n vertices which are indexed from 1 to n. For any pair ...

  7. Eclipse 4.2 failed to start after TEE is installed

    ---------------  VM Arguments---------------  jvm_args: -Dosgi.requiredJavaVersion=1.6 -Dhelp.lucene ...

  8. DVWA--登录页面错误问题 469 | | PHP Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\web\DVWA\dvwa\includes\dvwaPage.inc.php:469

    // MySQL PDO Prepared Statements (for impossible levels) $db = new PDO('mysql:host=' . $_DVWA[ 'db_s ...

  9. python + web自动化,点击不生效,提示“selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (117, 674)”

    前言: 在做web自动化时,遇到一个缩放了浏览器比例的操作,从100%缩小到80%,再进行点击的时候,弹出报错信息,无法点击 selenium.common.exceptions.ElementCli ...

随机推荐

  1. java图形界面之图形化按钮

    要将按钮图形化,只需创建一个ImageIcon对象,将图形路径赋予ImageIcon对象,然后将该对象传递给按钮即可. 此处涉及eclipse中图形的路径设置,包括(项目路径下.非项目路径下.相对路径 ...

  2. 洛谷P4360 [CEOI2004]锯木厂选址(dp 斜率优化)

    题意 题目链接 Sol 枚举第二个球放的位置,用前缀和推一波之后发现可以斜率优化 // luogu-judger-enable-o2 #include<bits/stdc++.h> #de ...

  3. php 判断字符串长度和字符串为纯数字字符串

    <?php $str="123456a"; $str_a=123456"; if(is_numeric($str)){ 返回 false }else{ 返回 tru ...

  4. IIS 部署 Python Django网站流程(受够了野路子)

    知道的,百度上搜出来的东西质量令人唏嘘.当你求助的时候多半还得靠自己,或者靠Google 介入正题,详细来一遍流程吧 当然,我是用Visual Studio 2019 来编辑开发Django项目的,如 ...

  5. Windows7设置锁屏密码

    1.设置开机密码 2.设置屏幕保护程序 注意,不要选择无,选择其他的都可以,比如:气泡.彩带.空白

  6. 如何在微软Windows平台上打造出你的Linux开发环境(转载)

    如何在微软Windows平台上打造出你的Linux开发环境 投递人 itwriter 发布于 2013-12-10 11:18 评论(1) 有348人阅读  原文链接  [收藏]  « » 英文原文: ...

  7. Promise 初步

    在JavaScript的世界中,所有代码都是单线程执行的. 由于这个“缺陷”,导致JavaScript的所有网络操作,浏览器事件,都必须是异步执行.异步执行可以用回调函数实现: function ca ...

  8. UML 运用于开发过程——总结

    UML -- 统一的图形语言 用例图:需求捕获,测试依据类图:静态系统结构对象图:对象之间的关联构件图:构件之间的关联部署图:构建的物理部署 以上几种图的作用:描述系统结构 顺序图:捕获时间顺序协作图 ...

  9. SQL索引未使用

    针对自己曾经经历过的一道面试题,那些情况不走索引,于是搜索网络和书籍的一些资料,整理如下: 1.查询谓词没有使用索引的主要边界,换句话说就是select *,可能会导致不走索引.比如,你查询的是SEL ...

  10. Vue2学习笔记:数据交互vue-resource

    基本语法 必须引入一个库:vue-resource github地址 // 基于全局Vue对象使用http Vue.http.get('/someUrl', [options]).then(succe ...