結果

問題 No.29 パワーアップ
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-26 02:11:13
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 1,013 bytes
コンパイル時間 3,076 ms
使用メモリ 37,708 KB
最終ジャッジ日時 2022-12-15 21:55:45
合計ジャッジ時間 6,675 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 101 ms
37,228 KB
testcase_01 AC 97 ms
37,352 KB
testcase_02 AC 99 ms
37,300 KB
testcase_03 AC 99 ms
37,332 KB
testcase_04 AC 97 ms
37,120 KB
testcase_05 AC 112 ms
37,476 KB
testcase_06 AC 105 ms
37,524 KB
testcase_07 AC 103 ms
37,180 KB
testcase_08 AC 99 ms
37,328 KB
testcase_09 AC 96 ms
37,188 KB
testcase_10 AC 113 ms
37,464 KB
testcase_11 AC 114 ms
37,704 KB
testcase_12 AC 98 ms
37,368 KB
testcase_13 AC 106 ms
37,324 KB
testcase_14 AC 113 ms
37,708 KB
testcase_15 AC 107 ms
37,428 KB
testcase_16 AC 110 ms
37,508 KB
testcase_17 AC 98 ms
37,328 KB
testcase_18 AC 108 ms
37,476 KB
testcase_19 AC 111 ms
37,340 KB
testcase_20 AC 102 ms
37,116 KB
testcase_21 AC 103 ms
37,360 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