結果

問題 No.412 花火大会
ユーザー GrenacheGrenache
提出日時 2016-08-13 11:07:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 2,819 bytes
コンパイル時間 3,969 ms
コンパイル使用メモリ 79,136 KB
実行使用メモリ 37,652 KB
最終ジャッジ日時 2024-04-25 06:28:24
合計ジャッジ時間 5,556 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
37,508 KB
testcase_01 AC 61 ms
37,500 KB
testcase_02 AC 58 ms
37,628 KB
testcase_03 AC 58 ms
37,392 KB
testcase_04 AC 60 ms
37,308 KB
testcase_05 AC 59 ms
37,196 KB
testcase_06 AC 61 ms
37,504 KB
testcase_07 AC 59 ms
37,456 KB
testcase_08 AC 60 ms
37,504 KB
testcase_09 AC 60 ms
37,016 KB
testcase_10 AC 58 ms
37,452 KB
testcase_11 AC 58 ms
37,360 KB
testcase_12 AC 59 ms
37,308 KB
testcase_13 AC 59 ms
37,000 KB
testcase_14 AC 58 ms
37,624 KB
testcase_15 AC 62 ms
37,272 KB
testcase_16 AC 59 ms
37,624 KB
testcase_17 AC 58 ms
37,424 KB
testcase_18 AC 60 ms
37,652 KB
testcase_19 AC 60 ms
37,512 KB
testcase_20 AC 60 ms
37,324 KB
testcase_21 AC 57 ms
37,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder412_1 {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	Printer pr = new Printer(System.out);

    	int[] bcd = new int[3];
    	for (int i = 0; i < 3; i++) {
    		bcd[i] = sc.nextInt();
    	}
    	Arrays.sort(bcd);

    	int n = sc.nextInt();

    	int[] e = new int[n];
    	for (int i = 0; i < n; i++) {
    		e[i] = sc.nextInt();
    	}
    	Arrays.sort(e);

    	int[] dp = new int[4];
    	dp[0] = 1;
    	for (int i = 0; i < n; i++) {
    		if (e[i] >= bcd[2]) {
    			dp[3] += dp[3];
    			dp[3] += dp[2];
    			dp[2] += dp[1];
    			dp[1] += dp[0];
    		} else if (e[i] >= bcd[1]) {
    			dp[2] += dp[2];
    			dp[2] += dp[1];
    			dp[1] += dp[0];
    		} else if (e[i] >= bcd[0]) {
    			dp[1] += dp[1];
    			dp[1] += dp[0];
    		} else {
    			dp[0] += dp[0];
    		}
    	}

    	pr.println(dp[3]);

/*
    	int[][] dp = new int[n + 1][4];
    	dp[0][0] = 1;
    	for (int i = 0; i < n; i++) {
    		dp[i + 1][0] = dp[i][0];
    		dp[i + 1][1] = dp[i][1];
    		dp[i + 1][2] = dp[i][2];
    		dp[i + 1][3] = dp[i][3];

    		if (e[i] >= bcd[2]) {
    			dp[i + 1][1] += dp[i][0];
    			dp[i + 1][2] += dp[i][1];
    			dp[i + 1][3] += dp[i][2];
    			dp[i + 1][3] += dp[i][3];
    		} else
    		if (e[i] >= bcd[1]) {
    			dp[i + 1][1] += dp[i][0];
    			dp[i + 1][2] += dp[i][1];
    			dp[i + 1][2] += dp[i][2];
    		} else
    		if (e[i] >= bcd[0]) {
    			dp[i + 1][1] += dp[i][0];
    			dp[i + 1][1] += dp[i][1];
    		} else {
    			dp[i + 1][0] += dp[i][0];
    		}
    	}

    	pr.println(dp[n][3]);
*/

        pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0