Submission #2099552


Source Code Expand

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		long[] a = new long[n];
		long[] b = new long[n];
		long[] c = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = Long.parseLong(sc.next());
		for (int i = 0; i < n; i++)
			b[i] = Long.parseLong(sc.next());
		for (int i = 0; i < n; i++)
			c[i] = Long.parseLong(sc.next());
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		long[] u = new long[n];
		int index = 0;
		for (int i = 0; i < n; i++) {
			while (index < n && a[index] < b[i])
				index++;
			if (i == 0)
				u[i] = index;
			else
				u[i] = u[i - 1] + index;
		}
		int[] l = new int[n];
		index = 0;
		for (int i = 0; i < n; i++) {
			while (index < n && b[index] < c[i])
				index++;
			l[i] = index;
		}
		long ans = 0;
		for (int i = 0; i < n; i++)
			if (l[i] != 0)
				ans += u[l[i] - 1];
		System.out.println(ans);

	}
}

Submission Info

Submission Time
Task C - Snuke Festival
User c_r_5
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1033 Byte
Status AC
Exec Time 702 ms
Memory 68576 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 32
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 634 ms 60816 KB
02.txt AC 702 ms 68576 KB
03.txt AC 686 ms 64396 KB
04.txt AC 566 ms 64564 KB
05.txt AC 552 ms 62460 KB
06.txt AC 527 ms 66972 KB
07.txt AC 505 ms 63404 KB
08.txt AC 523 ms 58636 KB
09.txt AC 479 ms 65960 KB
10.txt AC 518 ms 59568 KB
11.txt AC 496 ms 59948 KB
12.txt AC 464 ms 63052 KB
13.txt AC 682 ms 63528 KB
14.txt AC 591 ms 66348 KB
15.txt AC 632 ms 61276 KB
16.txt AC 619 ms 64316 KB
17.txt AC 618 ms 61800 KB
18.txt AC 591 ms 64920 KB
19.txt AC 615 ms 61368 KB
20.txt AC 477 ms 63172 KB
21.txt AC 426 ms 61388 KB
22.txt AC 576 ms 62148 KB
23.txt AC 614 ms 59876 KB
24.txt AC 621 ms 63176 KB
25.txt AC 592 ms 64284 KB
26.txt AC 90 ms 19284 KB
27.txt AC 90 ms 18900 KB
28.txt AC 90 ms 19028 KB
29.txt AC 90 ms 19796 KB
s1.txt AC 91 ms 19412 KB
s2.txt AC 93 ms 19796 KB
s3.txt AC 93 ms 21844 KB