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>
#define ll long long
#define ld long double
#define ull unsigned long long
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ins insert
#define setpre(i) setprecision(i) << fixed
#define foru(i,a,b) for(int i = a; i <= b; i++)
#define ford(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<vector<pll> > vvl;
typedef vector<int> vi;
const ll inf = INT_MIN;
const ll mod = 1e9+7;
map<ll, int> cntx;
map<ll, int> cnty;
ll x[1501], y[1501];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int n,m; cin >> n >> m;
foru(i,1,n) {
cin >> y[i];
foru(j,1,i-1) {
cnty[y[i]-y[j]]++;
}
}
foru(i,1,m) {
cin >> x[i];
foru(j,1,i-1) {
cntx[x[i]-x[j]]++;
}
}
ll ans = 0;
for(auto v : cnty) {
//cout << v.fi << " " << v.se << " " << cntx[v.fi] << "\n";
ans += (v.se*cntx[v.fi]);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |