結果

問題 No.794 チーム戦 (2)
ユーザー tentententen
提出日時 2020-09-02 23:00:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 979 ms / 1,500 ms
コード長 929 bytes
コンパイル時間 2,367 ms
コンパイル使用メモリ 75,172 KB
実行使用メモリ 68,488 KB
最終ジャッジ日時 2024-05-01 18:29:53
合計ジャッジ時間 24,421 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
54,176 KB
testcase_01 AC 138 ms
54,004 KB
testcase_02 AC 138 ms
53,904 KB
testcase_03 AC 135 ms
54,020 KB
testcase_04 AC 138 ms
54,276 KB
testcase_05 AC 138 ms
54,332 KB
testcase_06 AC 141 ms
54,084 KB
testcase_07 AC 141 ms
54,260 KB
testcase_08 AC 138 ms
53,828 KB
testcase_09 AC 141 ms
54,312 KB
testcase_10 AC 138 ms
54,256 KB
testcase_11 AC 137 ms
54,332 KB
testcase_12 AC 137 ms
54,120 KB
testcase_13 AC 137 ms
53,928 KB
testcase_14 AC 961 ms
68,032 KB
testcase_15 AC 912 ms
68,152 KB
testcase_16 AC 979 ms
68,048 KB
testcase_17 AC 956 ms
68,384 KB
testcase_18 AC 911 ms
68,488 KB
testcase_19 AC 959 ms
68,132 KB
testcase_20 AC 933 ms
67,796 KB
testcase_21 AC 950 ms
67,976 KB
testcase_22 AC 777 ms
63,100 KB
testcase_23 AC 760 ms
60,200 KB
testcase_24 AC 689 ms
59,516 KB
testcase_25 AC 660 ms
59,356 KB
testcase_26 AC 679 ms
59,560 KB
testcase_27 AC 743 ms
64,224 KB
testcase_28 AC 722 ms
63,988 KB
testcase_29 AC 769 ms
63,924 KB
testcase_30 AC 721 ms
63,584 KB
testcase_31 AC 723 ms
63,784 KB
testcase_32 AC 730 ms
63,888 KB
testcase_33 AC 723 ms
63,092 KB
testcase_34 AC 780 ms
62,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int k = sc.nextInt();
    	int[] arr = new int[n];
    	for (int i = 0; i < n; i++) {
    	    arr[i] = sc.nextInt();
    	}
    	Arrays.sort(arr);
    	long ans = 1;
    	if (k - arr[n - 1] < arr[0]) {
    	    System.out.println(0);
    	    return;
    	}
    	int right = n - 1;
    	int left = 0;
    	int count = 0;
    	while (right >= n / 2) {
    	    while (left + 1 < right && k - arr[right] >= arr[left + 1]) {
    	        left++;
    	    }
    	    if (left + 1 <= count) {
    	        System.out.println(0);
    	        return;
    	    }
    	    ans *= left + 1 - count;
    	    ans %= MOD;
    	    count++;
    	    right--;
    	    left = Math.min(left, right - 1);
    	}
    	System.out.println(ans);
	}
}
0