結果
| 問題 |
No.29 パワーアップ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-15 19:55:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 5,000 ms |
| コード長 | 973 bytes |
| コンパイル時間 | 3,305 ms |
| コンパイル使用メモリ | 81,040 KB |
| 実行使用メモリ | 43,636 KB |
| 最終ジャッジ日時 | 2025-10-24 21:18:26 |
| 合計ジャッジ時間 | 5,346 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class No29_3{
public static void main(String[] args) throws IOException{
//パワーアップ 作り直し2回目
int count = 0 , i;
String[] text = readStr();
ArrayList<String> al = new ArrayList<>();
int N = Integer.parseInt(text[0]);
for(i = 1;i <= N;i++) {
for(String str : text[i].split(" ")) {
if(al.contains(str)) {
count++;
al.remove(str);
}else {
al.add(str);
}
}
}
count += (int)(al.size() / 4);
System.out.println(count);
}
public static String[] readStr() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> list = new ArrayList<>();
do {
list.add(br.readLine());
}while(br.ready());
br.close();
String[] text = new String[list.size()];
list.toArray(text);
return text;
}
}