結果
| 問題 |
No.1623 三角形の制作
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-05 22:13:59 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,435 bytes |
| コンパイル時間 | 2,289 ms |
| コンパイル使用メモリ | 77,568 KB |
| 実行使用メモリ | 534,944 KB |
| 最終ジャッジ日時 | 2024-07-18 16:26:47 |
| 合計ジャッジ時間 | 34,377 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 MLE * 4 |
ソースコード
import java.util.*;
class Main{
static int max(int x, int y){
return x > y ? x : y;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int M = 5000;
int n = Integer.parseInt(sc.next());
int Rcnt[] = new int[M + 1];
int Gcnt[] = new int[M + 1];
int Bcnt[] = new int[M + 1];
int x;
for (int i = 0; i < n; i++){
x = Integer.parseInt(sc.next());
Rcnt[x]++;
}
for (int i = 0; i < n; i++){
x = Integer.parseInt(sc.next());
Gcnt[x]++;
}
for (int i = 0; i < n; i++){
x = Integer.parseInt(sc.next());
Bcnt[x]++;
}
long C[][] = new long[M + 2][2 * M + 2];
for (int i = 1; i <= M; i++){
if (Gcnt[i] == 0) continue;
for (int j = 1; j <= M; j++){
C[max(i, j) + 1][i + j + 1] += (long)Gcnt[i] * Bcnt[j];
}
}
for (int i = 0; i < M + 1; i++){
for (int j = 0; j < 2 * M + 1; j++){
C[i + 1][j + 1] += C[i][j + 1] + C[i + 1][j] - C[i][j];
}
}
long ans = 0;
for (int i = 1; i <= M; i++){
long tmp = C[i + 1][2 * M + 1] + C[1][i + 1] - C[i + 1][i + 1] - C[1][2 * M + 1];
ans += (long)Rcnt[i] * tmp;
}
System.out.println(ans);
}
}