結果
問題 | No.29 パワーアップ |
ユーザー |
|
提出日時 | 2022-05-15 19:55:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 55 ms / 5,000 ms |
コード長 | 973 bytes |
コンパイル時間 | 4,079 ms |
コンパイル使用メモリ | 78,516 KB |
実行使用メモリ | 50,348 KB |
最終ジャッジ日時 | 2024-09-13 05:54:42 |
合計ジャッジ時間 | 6,349 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; } }