• Bio
  • Accepted Problems
  • Recent Activities
  • Recent Solutions
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m,x[40010];
ll r[15010][5],s[15010],a[15010];
int main(){
	scanf("%d%d",&m,&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&x[i]);
		a[x[i]]++;
	}
	for(int i=1;i<=4500;i++){
		for(int j=1;j<=m;j++){
			if(j+i<=m){
				s[j]=a[j]*a[i+j];
			}
			else break;
		}
		for(int j=m;j>=1;j--){
			s[j]+=s[j+1];
		}
		for(int j=1;j<=m;j++){
			int u=j+8*i+1;
			if(j>=m) break;
			r[j][1]+=s[u];
		}
	}
}






























Problem Tags

math
11
implementation
7
brute force
4
*900
4
*1000
4
strings
3
number theory
3
greedy
3
constructive algorithms
3
combinatorics
2
*800
2
dp
2
*1300
2
sortings
2
probabilities
1
two pointers
1
*2400
1
games
1
*1700
1
*1500
1