-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2143.cpp
65 lines (65 loc) · 1.41 KB
/
2143.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
#define MAX 2000000000
#define MOD 1000000007
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<utility>
#include<math.h>
#include<memory.h>
#include<stack>
#include<string>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef queue<pair<int, int>> qii;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;
map<ll, ll> m1;
int main() {
cin.tie(NULL); ios_base::sync_with_stdio(false);
ll t;
cin >> t;
int n;
cin >> n;
vector<int> v1(n);
for (int i = 0; i < n; i++) {
cin >> v1[i];
}
int m;
cin >> m;
vector<int> v2(m);
for (int i = 0; i < m; i++) {
cin >> v2[i];
}
for (int i = 0; i < n; i++) {
ll now = 0;
for (int j = i; j < n; j++) {
now += v1[j];
m1[now]++;
}
}
vector<ll> tmp;
for (int i = 0; i < m; i++) {
ll now = 0;
for (int j = i; j < m; j++) {
now += v2[j];
tmp.push_back(now);
}
}
int size = tmp.size();
ll ans = 0;
for (int i = 0; i < size; i++) {
if (m1[t - tmp[i]]) {
ans += m1[t - tmp[i]];
}
}
cout << ans;
return 0;
}