-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWWALK.cpp
67 lines (49 loc) · 1.04 KB
/
WWALK.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
// Created by Sagar Pawar on 30/05/20.
//
/**
Problem: WWALK.cpp
Algorithm:
Time Complexity:
Learning:
Tags:
**/
#include <bits/stdc++.h>
#define loop(i, s, e) for(int i=s; i<e; i++)
#define ll long long
#define ui unsigned int
#define MAX_INT 2147483647
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
char *testFile = (char *) "/Users/sagarpawar/CLionProjects/ccdsap/LTIME84B/test/WWALK.txt";
freopen(testFile, "r", stdin);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n), b(n);
loop(i,0, n){
cin >> a[i];
}
loop(i, 0, n){
cin >> b[i];
}
ll wd = 0;
ll distA = 0, distB = 0;
loop(i, 0, n){
if(distA == distB && a[i] == b[i]){
wd += a[i];
}
distA += a[i];
distB += b[i];
}
cout << wd << "\n";
}
return 0;
}