結果
| 問題 | No.1279 Array Battle |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-11-09 09:16:11 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 103 ms / 2,000 ms |
| + 696µs | |
| コード長 | 1,315 bytes |
| 記録 | |
| コンパイル時間 | 2,919 ms |
| コンパイル使用メモリ | 84,668 KB |
| 実行使用メモリ | 45,408 KB |
| 最終ジャッジ日時 | 2026-08-23 09:42:59 |
| 合計ジャッジ時間 | 4,648 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
import java.util.*;
public class Main {
static int n;
static int[] aArr;
static int[] bArr;
static int max = 0;
static int count = 0;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
aArr = new int[n];
for (int i = 0; i < n; i++) {
aArr[i] = sc.nextInt();
}
bArr = new int[n];
for (int i = 0; i < n; i++) {
bArr[i] = sc.nextInt();
}
boolean[] used = new boolean[n];
int[] arr = new int[n];
setPerm(used, arr, 0);
System.out.println(count);
}
static void setPerm(boolean[] used, int[] arr, int idx) {
if (idx == n) {
int value = 0;
for (int i = 0; i < n; i++) {
value += Math.max(0, bArr[i] - aArr[arr[i]]);
}
if (max < value) {
max = value;
count = 1;
} else if (max == value) {
count++;
}
return;
}
for (int i = 0; i < n; i++) {
if (used[i]) {
continue;
}
used[i] = true;
arr[idx] = i;
setPerm(used, arr, idx + 1);
used[i] = false;
}
}
}
tenten