#include <bits/stdc++.h>
using namespace std;
int H, V;
vector<int> h, v;
void read() {
cin >> H >> V;
h.resize(H);
v.resize(V);
for (auto &a : h) cin >> a;
for (auto &a : v) cin >> a;
}
map<int, int> calcDiff(vector<int> const &v) {
map<int, int> ret;
for (int i = 0; i < (int)v.size(); ++i) {
for (int j = i + 1; j < (int)v.size(); ++j) {
ret[v[j] - v[i]]++;
}
}
return ret;
}
void solve() {
read();
auto mh = calcDiff(h);
auto mv = calcDiff(v);
using ll = long long;
ll ans = 0;
for (auto &[key, val] : mh) {
ans += val * mv[key];
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
230 ms |
25684 KB |
Output is correct |
7 |
Correct |
198 ms |
25708 KB |
Output is correct |
8 |
Correct |
177 ms |
25708 KB |
Output is correct |
9 |
Correct |
193 ms |
24960 KB |
Output is correct |
10 |
Correct |
10 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
230 ms |
25684 KB |
Output is correct |
7 |
Correct |
198 ms |
25708 KB |
Output is correct |
8 |
Correct |
177 ms |
25708 KB |
Output is correct |
9 |
Correct |
193 ms |
24960 KB |
Output is correct |
10 |
Correct |
10 ms |
876 KB |
Output is correct |
11 |
Correct |
2211 ms |
158612 KB |
Output is correct |
12 |
Correct |
2230 ms |
158616 KB |
Output is correct |
13 |
Correct |
2233 ms |
158572 KB |
Output is correct |
14 |
Correct |
2184 ms |
156884 KB |
Output is correct |
15 |
Correct |
78 ms |
1772 KB |
Output is correct |