結果
問題 | No.1623 三角形の制作 |
ユーザー | tenten |
提出日時 | 2023-04-17 16:30:46 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 538 ms / 2,000 ms |
コード長 | 2,187 bytes |
コンパイル時間 | 3,665 ms |
コンパイル使用メモリ | 96,552 KB |
実行使用メモリ | 54,184 KB |
最終ジャッジ日時 | 2024-04-20 20:30:05 |
合計ジャッジ時間 | 11,809 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
37,108 KB |
testcase_01 | AC | 55 ms
37,356 KB |
testcase_02 | AC | 438 ms
47,660 KB |
testcase_03 | AC | 423 ms
50,764 KB |
testcase_04 | AC | 400 ms
47,996 KB |
testcase_05 | AC | 538 ms
52,664 KB |
testcase_06 | AC | 253 ms
45,160 KB |
testcase_07 | AC | 384 ms
48,092 KB |
testcase_08 | AC | 243 ms
44,776 KB |
testcase_09 | AC | 406 ms
48,644 KB |
testcase_10 | AC | 432 ms
48,908 KB |
testcase_11 | AC | 449 ms
47,824 KB |
testcase_12 | AC | 240 ms
44,124 KB |
testcase_13 | AC | 269 ms
46,116 KB |
testcase_14 | AC | 253 ms
45,040 KB |
testcase_15 | AC | 369 ms
48,224 KB |
testcase_16 | AC | 367 ms
51,028 KB |
testcase_17 | AC | 374 ms
49,836 KB |
testcase_18 | AC | 439 ms
54,184 KB |
testcase_19 | AC | 263 ms
46,256 KB |
testcase_20 | AC | 55 ms
37,528 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long[][] counts = new long[3][3001]; for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { counts[i][sc.nextInt()]++; } } for (int i = 1; i < counts[2].length; i++) { counts[2][i] += counts[2][i - 1]; } long ans = 0; for (int i = 1; i < counts[0].length; i++) { if (counts[0][i] == 0) { continue; } for (int j = 1; j <= i; j++) { if (counts[1][j] == 0) { continue; } ans += counts[0][i] * counts[1][j] * (counts[2][i] - counts[2][Math.max(0, i - j)]); } } System.out.println(ans); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }