#include <bits/stdc++.h>
using namespace std;
queue<int> a, b;
signed main(){
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; ++i){
int x; cin >> x;
a.push(x);
}
for(int i = 1; i <= m; ++i){
int x; cin >> x;
b.push(x);
}
int cnt = 0;
while(a.size() || b.size()){
int top1 = a.front(), top2 = b.front();
a.pop(), b.pop();
while(top1 != top2){
if(top1 < top2){
top1 += a.front();
++cnt;
a.pop();
}else{
top2 += b.front();
++cnt;
b.pop();
}
}
}
cout << cnt << endl;
return 0;
}
0 回复
0 转发
0 喜欢
6 阅读



