#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map>
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
#define MOD 1000000007
#define int long long
#define ff first
#define ss second
#define endl '\n'
void solve(){
int n,m; cin>>n>>m;
vector<int> y(n+1),x(m+1);
for(int i=1; i<=n; i++) cin>>y[i];
for(int i=1; i<=m; i++) cin>>x[i];
map<int,int> mp;
for(int i=1; i<=n; i++){
for(int j=i+1; j<=n; j++){
mp[y[j]-y[i]]++;
}
}
int ans=0;
for(int i=1; i<=m; i++){
for(int j=i+1; j<=m; j++){
ans+=mp[x[j]-x[i]];
}
}
cout<<ans;
}
signed main(){
// freopen("file.in", "r", stdin);
// freopen("file.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
cout<<endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
157 ms |
22896 KB |
Output is correct |
7 |
Correct |
124 ms |
22868 KB |
Output is correct |
8 |
Correct |
131 ms |
22820 KB |
Output is correct |
9 |
Correct |
122 ms |
22096 KB |
Output is correct |
10 |
Correct |
7 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
157 ms |
22896 KB |
Output is correct |
7 |
Correct |
124 ms |
22868 KB |
Output is correct |
8 |
Correct |
131 ms |
22820 KB |
Output is correct |
9 |
Correct |
122 ms |
22096 KB |
Output is correct |
10 |
Correct |
7 ms |
860 KB |
Output is correct |
11 |
Correct |
1901 ms |
141096 KB |
Output is correct |
12 |
Correct |
1748 ms |
140872 KB |
Output is correct |
13 |
Correct |
1819 ms |
140800 KB |
Output is correct |
14 |
Correct |
1860 ms |
139224 KB |
Output is correct |
15 |
Correct |
78 ms |
1316 KB |
Output is correct |