結果

問題 No.29 パワーアップ
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-26 02:11:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 5,000 ms
コード長 1,013 bytes
コンパイル時間 3,773 ms
コンパイル使用メモリ 74,492 KB
実行使用メモリ 41,748 KB
最終ジャッジ日時 2024-04-26 21:51:42
合計ジャッジ時間 7,568 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,148 KB
testcase_01 AC 131 ms
41,120 KB
testcase_02 AC 114 ms
40,332 KB
testcase_03 AC 117 ms
40,996 KB
testcase_04 AC 116 ms
41,012 KB
testcase_05 AC 136 ms
41,528 KB
testcase_06 AC 138 ms
41,592 KB
testcase_07 AC 134 ms
41,584 KB
testcase_08 AC 130 ms
41,628 KB
testcase_09 AC 116 ms
41,488 KB
testcase_10 AC 142 ms
41,636 KB
testcase_11 AC 144 ms
41,360 KB
testcase_12 AC 126 ms
41,156 KB
testcase_13 AC 141 ms
41,312 KB
testcase_14 AC 143 ms
41,748 KB
testcase_15 AC 137 ms
41,084 KB
testcase_16 AC 142 ms
41,292 KB
testcase_17 AC 137 ms
41,364 KB
testcase_18 AC 138 ms
41,212 KB
testcase_19 AC 128 ms
40,908 KB
testcase_20 AC 129 ms
41,280 KB
testcase_21 AC 119 ms
39,776 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