[Link] https://www.acmicpc.net/problem/3273
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br;
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
int n = toi(br.readLine());
boolean[] ex = new boolean[1000001];
String[] line = br.readLine().split(" ");
for(int i = 0; i < n; i++) if(toi(line[i]) != 0) ex[toi(line[i])] = true;
int x = toi(br.readLine()), cnt = 0;
for(int i = Math.max(1, x - 1000000); i <= (x - 1) / 2; i++)
if(ex[i] && ex[x - i]) cnt++;
System.out.print(cnt);
}
static int toi(String s) { return Integer.parseInt(s); }
static int[] getArr() throws IOException { return Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); }
}