結果
| 問題 |
No.29 パワーアップ
|
| ユーザー |
|
| 提出日時 | 2021-11-18 22:53:44 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,728 bytes |
| コンパイル時間 | 2,324 ms |
| コンパイル使用メモリ | 83,212 KB |
| 実行使用メモリ | 45,448 KB |
| 最終ジャッジ日時 | 2025-10-24 21:17:44 |
| 合計ジャッジ時間 | 4,555 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 WA * 10 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.stream.Stream;
class Main {
public static void main(String[] args) {
no29();
}
// No.29 パワーアップ
private static void no29() {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// 敵を倒す回数
int turn;
// もらえるアイテム
int[] itemList;
try {
String co = reader.readLine();
turn = Integer.parseInt(co);
int[][] items = new int[turn][];
itemList = new int[turn * 3];
for (int i = 0, k = 0; i < turn; i++) {
String line = reader.readLine();
items[i] = Stream.of(line.split(" ")).mapToInt(Integer::parseInt).toArray();
for (int j = 0; j < 3; j++) {
itemList[k] = items[i][j];
k++;
}
}
reader.close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Arrays.sort(itemList);
// レベルアップ回数
int count = 0;
// 重複値と任意の値をカウントする
for (int i = 0, j = 0; i < itemList.length; i++) {
if (i == itemList.length - 1) {
j++;
count += (j / 4);
break;
}
if (itemList[i] == itemList[i + 1]) {
count++;
i++;
} else {
j++;
}
}
System.out.println(count);
}
}