結果

問題 No.29 パワーアップ
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-26 02:11:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 1,013 bytes
コンパイル時間 3,469 ms
コンパイル使用メモリ 71,504 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-08-09 07:07:21
合計ジャッジ時間 7,633 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,076 KB
testcase_01 AC 123 ms
56,264 KB
testcase_02 AC 122 ms
56,220 KB
testcase_03 AC 127 ms
55,748 KB
testcase_04 AC 123 ms
56,036 KB
testcase_05 AC 138 ms
55,952 KB
testcase_06 AC 138 ms
55,764 KB
testcase_07 AC 130 ms
56,156 KB
testcase_08 AC 128 ms
56,244 KB
testcase_09 AC 126 ms
55,740 KB
testcase_10 AC 142 ms
56,168 KB
testcase_11 AC 141 ms
55,960 KB
testcase_12 AC 126 ms
55,832 KB
testcase_13 AC 138 ms
55,700 KB
testcase_14 AC 141 ms
55,392 KB
testcase_15 AC 139 ms
55,944 KB
testcase_16 AC 136 ms
55,876 KB
testcase_17 AC 131 ms
55,912 KB
testcase_18 AC 131 ms
56,296 KB
testcase_19 AC 131 ms
55,484 KB
testcase_20 AC 122 ms
54,256 KB
testcase_21 AC 122 ms
56,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Scanner;

public class No29 {

	public static void main(String[] args) throws IOException, NumberFormatException{
		
		/*重なった数字を取っていくのではなく、配列(対応する番号の箱)に入れていく*/
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] item = new int[10];
		for(int i=0; i < N * 3; i++){
			int temp = sc.nextInt();
			item[temp-1]++; //入力した数値と配列の数字にはズレがあるので、-1して配列に入れる
		}
		/************************************************************************/
		
		/*1つの箱(配列)に2つ以上重なった数字が入っているかチェック
		 * /2した分レベルアップ、奇数なら1つ残して計4つ余れば1レベルアップ*/
		
		int level = 0; int amari =0;
		for(int i =0; i <10; i++){
			level += item[i]/2;
			item[i] %= 2;
			amari += item[i];
		}
		level += amari / 4;
		System.out.print(level);
		sc.close();
		
		}

}
0