This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |