結果

問題 No.29 パワーアップ
ユーザー 水野嶺水野嶺
提出日時 2020-05-28 13:51:25
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 595 bytes
コンパイル時間 2,341 ms
コンパイル使用メモリ 72,696 KB
実行使用メモリ 57,740 KB
最終ジャッジ日時 2023-08-03 06:29:58
合計ジャッジ時間 5,375 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
57,740 KB
testcase_01 AC 108 ms
55,840 KB
testcase_02 AC 107 ms
55,844 KB
testcase_03 AC 112 ms
55,984 KB
testcase_04 AC 109 ms
55,868 KB
testcase_05 AC 119 ms
56,252 KB
testcase_06 AC 125 ms
55,628 KB
testcase_07 AC 117 ms
55,904 KB
testcase_08 AC 113 ms
55,868 KB
testcase_09 AC 108 ms
55,796 KB
testcase_10 AC 121 ms
56,196 KB
testcase_11 AC 121 ms
55,688 KB
testcase_12 AC 111 ms
55,772 KB
testcase_13 AC 118 ms
55,564 KB
testcase_14 AC 120 ms
56,136 KB
testcase_15 AC 117 ms
55,716 KB
testcase_16 AC 118 ms
55,844 KB
testcase_17 AC 111 ms
55,812 KB
testcase_18 AC 119 ms
55,864 KB
testcase_19 AC 115 ms
55,952 KB
testcase_20 AC 113 ms
55,904 KB
testcase_21 AC 111 ms
54,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) 
	{
		// 入力値の読み込み
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayList<String> a=new ArrayList<>();
		for(int i=0;i<3*n;i++){
			a.add(sc.next());
		}
		
		int two=0;
		int ans =0;
		
		// カウント
		TreeSet<String> b=new TreeSet<>(a);
		
		
		for(String s:b){
			int coun=0;
			for(String c:a){
				if(s.equals(c))coun++;
			}
			if(coun >= 2){
				two += coun/2;
			}
		}
		
		ans = two + (3*n-2*two)/4;
		
		System.out.println(ans);
	}
}
0