結果

問題 No.1285 ゴミ捨て
ユーザー xRS43BofaUEZ5gcxRS43BofaUEZ5gc
提出日時 2021-03-10 09:31:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 874 bytes
コンパイル時間 3,355 ms
コンパイル使用メモリ 74,964 KB
実行使用メモリ 76,308 KB
最終ジャッジ日時 2024-04-20 05:48:44
合計ジャッジ時間 26,451 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
54,288 KB
testcase_01 AC 107 ms
54,140 KB
testcase_02 AC 108 ms
53,740 KB
testcase_03 AC 112 ms
53,780 KB
testcase_04 AC 106 ms
53,884 KB
testcase_05 AC 113 ms
54,064 KB
testcase_06 AC 104 ms
53,088 KB
testcase_07 TLE -
testcase_08 AC 200 ms
57,336 KB
testcase_09 WA -
testcase_10 AC 1,975 ms
69,452 KB
testcase_11 AC 1,794 ms
69,256 KB
testcase_12 AC 1,150 ms
69,340 KB
testcase_13 WA -
testcase_14 TLE -
testcase_15 WA -
testcase_16 AC 403 ms
59,708 KB
testcase_17 AC 405 ms
59,444 KB
testcase_18 AC 425 ms
59,208 KB
testcase_19 AC 625 ms
59,484 KB
testcase_20 AC 450 ms
59,104 KB
testcase_21 AC 468 ms
59,512 KB
testcase_22 TLE -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class HelloWorld {

	    public static void main(String[] args) throws Exception {

	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	int[] ai = new int[n];
	    	for (int i = 0; i < n; i ++) {
	    		ai[i] = sc.nextInt();
	    	}
	    	sc.close();

	    	Arrays.sort(ai);
	    	int count = 0;
	    	for (int i = n - 1; i >= 1; i --) {
	    		int size_now = 0;
	    		if (ai[i] == 0) {
	    			i --;
	    		}else {
	    			size_now = ai[i];
	    			ai[i] = 0;
	    			count ++;
	    		}


	    		for (int j = i - 1; j >=0; j --) {
	    			if (ai[j] == 0 ) {
		    			j --;
		    		}else if(size_now - 1 > ai[j]){
		    			size_now = ai[j];
		    			ai[j] = 0;
		    		}
	    		}

	    	}

	    	if (ai[0] != 0) {
	    		count ++;
	    	}


	    	System.out.println(count);
	    	}

	    }
0