結果

問題 No.29 パワーアップ
ユーザー 水野嶺水野嶺
提出日時 2020-05-28 13:51:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 595 bytes
コンパイル時間 2,685 ms
コンパイル使用メモリ 75,776 KB
実行使用メモリ 41,840 KB
最終ジャッジ日時 2024-04-21 05:36:59
合計ジャッジ時間 5,993 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
41,092 KB
testcase_01 AC 115 ms
41,112 KB
testcase_02 AC 120 ms
41,716 KB
testcase_03 AC 108 ms
40,112 KB
testcase_04 AC 118 ms
41,156 KB
testcase_05 AC 129 ms
41,840 KB
testcase_06 AC 125 ms
41,432 KB
testcase_07 AC 123 ms
41,204 KB
testcase_08 AC 121 ms
41,232 KB
testcase_09 AC 123 ms
41,468 KB
testcase_10 AC 128 ms
41,544 KB
testcase_11 AC 130 ms
41,480 KB
testcase_12 AC 118 ms
41,364 KB
testcase_13 AC 134 ms
41,164 KB
testcase_14 AC 136 ms
41,280 KB
testcase_15 AC 129 ms
41,688 KB
testcase_16 AC 127 ms
41,504 KB
testcase_17 AC 111 ms
40,260 KB
testcase_18 AC 122 ms
41,248 KB
testcase_19 AC 134 ms
41,560 KB
testcase_20 AC 117 ms
41,176 KB
testcase_21 AC 118 ms
41,440 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