#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n, m;
vi hor, ver;
int main(){
cin>>n>>m;
hor.resize(n);
ver.resize(m);
for(int i = 0; i < n; i++) cin>>hor[i];
for(int j = 0; j < m; j++) cin>>ver[j];
map<int,int> dif_hor, dif_ver;
sort(hor.begin(), hor.end());
sort(ver.begin(), ver.end());
for(int i = 0; i < n; i++){
for(int j = i+1; j < n; j++)
dif_hor[hor[i]-hor[j]]++;
}
for(int i = 0; i < m; i++){
for(int j = i +1; j < m; j++)
dif_ver[ver[i]-ver[j]]++;
}
ll ans = 0;
for(auto t : dif_hor){
ans += t.second * dif_ver[t.first];
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
152 ms |
25564 KB |
Output is correct |
7 |
Correct |
152 ms |
25432 KB |
Output is correct |
8 |
Correct |
157 ms |
25560 KB |
Output is correct |
9 |
Correct |
158 ms |
24740 KB |
Output is correct |
10 |
Correct |
10 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
152 ms |
25564 KB |
Output is correct |
7 |
Correct |
152 ms |
25432 KB |
Output is correct |
8 |
Correct |
157 ms |
25560 KB |
Output is correct |
9 |
Correct |
158 ms |
24740 KB |
Output is correct |
10 |
Correct |
10 ms |
724 KB |
Output is correct |
11 |
Correct |
1724 ms |
158588 KB |
Output is correct |
12 |
Correct |
1632 ms |
158404 KB |
Output is correct |
13 |
Correct |
1744 ms |
158376 KB |
Output is correct |
14 |
Correct |
1796 ms |
156596 KB |
Output is correct |
15 |
Correct |
69 ms |
1484 KB |
Output is correct |