#include <bits/stdc++.h>
using namespace std;
#define oo 1e9
#define fi first
#define se second
#define sp(iiii) setprecision(iiii)
#define IO ios_base::sync_with_stdio(false); cin.tie(0)
#define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa))
#define cntbit(xxxx) __builtin_popcount(xxxx)
#define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1)
#define _cos(xxxx) cos(xxxx*acos(-1)/180)
#define _sin(xxxx) sin(xxxx*acos(-1)/180)
#define _tan(xxxx) tan(xxxx*acos(-1)/180)
#define PE cout<<fixed
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pair<int,int>,int> piii;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,long long> plll;
const ld pi=acos(-1);
ll n,m,a[5009],b[5009],i,j,res;
map<ll,ll> sl;
int main(){
IO;
cin>>n>>m;
for (i=1;i<=n;i++) {
cin>>a[i];
}
for (i=1;i<=m;i++) {
cin>>b[i];
}
for (i=1;i<=n;i++) {
for (j=i+1;j<=n;j++) {
sl[a[j]-a[i]]++;
}
}
for (i=1;i<=m;i++) {
for (j=i+1;j<=m;j++) {
res+=sl[b[j]-b[i]];
}
}
cout<<res<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
210 ms |
22908 KB |
Output is correct |
7 |
Correct |
205 ms |
22776 KB |
Output is correct |
8 |
Correct |
206 ms |
22812 KB |
Output is correct |
9 |
Correct |
215 ms |
22152 KB |
Output is correct |
10 |
Correct |
12 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
210 ms |
22908 KB |
Output is correct |
7 |
Correct |
205 ms |
22776 KB |
Output is correct |
8 |
Correct |
206 ms |
22812 KB |
Output is correct |
9 |
Correct |
215 ms |
22152 KB |
Output is correct |
10 |
Correct |
12 ms |
768 KB |
Output is correct |
11 |
Correct |
2609 ms |
141040 KB |
Output is correct |
12 |
Correct |
2512 ms |
140904 KB |
Output is correct |
13 |
Correct |
2415 ms |
140920 KB |
Output is correct |
14 |
Correct |
2316 ms |
139172 KB |
Output is correct |
15 |
Correct |
86 ms |
1400 KB |
Output is correct |