結果

問題 No.616 へんなソート
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2017-12-16 00:13:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 659 ms / 2,000 ms
コード長 2,225 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 78,316 KB
実行使用メモリ 330,568 KB
最終ジャッジ日時 2024-05-08 12:18:47
合計ジャッジ時間 7,076 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
37,012 KB
testcase_01 AC 46 ms
36,904 KB
testcase_02 AC 46 ms
36,904 KB
testcase_03 AC 50 ms
37,368 KB
testcase_04 AC 56 ms
37,512 KB
testcase_05 AC 45 ms
36,760 KB
testcase_06 AC 52 ms
36,928 KB
testcase_07 AC 48 ms
36,992 KB
testcase_08 AC 53 ms
37,008 KB
testcase_09 AC 73 ms
38,416 KB
testcase_10 AC 48 ms
36,884 KB
testcase_11 AC 61 ms
38,048 KB
testcase_12 AC 111 ms
47,020 KB
testcase_13 AC 390 ms
173,164 KB
testcase_14 AC 94 ms
45,780 KB
testcase_15 AC 50 ms
37,012 KB
testcase_16 AC 62 ms
38,304 KB
testcase_17 AC 376 ms
171,988 KB
testcase_18 AC 193 ms
85,576 KB
testcase_19 AC 174 ms
76,112 KB
testcase_20 AC 55 ms
37,384 KB
testcase_21 AC 86 ms
40,164 KB
testcase_22 AC 162 ms
55,280 KB
testcase_23 AC 47 ms
37,192 KB
testcase_24 AC 46 ms
37,168 KB
testcase_25 AC 48 ms
37,168 KB
testcase_26 AC 135 ms
55,264 KB
testcase_27 AC 126 ms
51,660 KB
testcase_28 AC 659 ms
328,608 KB
testcase_29 AC 650 ms
330,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


class Main {
    static final long MOD=1000000007;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int k=sc.nextInt();
        int[]a=new int[n];
        for(int i=0;i<n;++i)a[i]=sc.nextInt();
        long[][]dp=new long[n+1][n*n];
        dp[0][0]=1;
        for(int i=0;i<n;++i){
            int u=i;
            int nxt=i+1;
            Arrays.fill(dp[nxt],0);
            for(int j=0;j<n*n;++j){
                if(j+i+1<n*n)
                    dp[nxt][j+i+1]=(dp[nxt][j+i+1]-dp[u][j]+MOD)%MOD;
                dp[nxt][j]=(dp[nxt][j]+dp[u][j])%MOD;
            }
            for(int j=1;j<n*n;++j)
                dp[nxt][j]=(dp[nxt][j]+dp[nxt][j-1])%MOD;
        }
        long ans=0;
        for(int i=0;i<=k;++i)
            ans=(ans+dp[n][i])%MOD;
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}
0