結果

問題 No.1111 コード進行
ユーザー shojin_proshojin_pro
提出日時 2020-07-10 22:49:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 3,091 bytes
コンパイル時間 2,933 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 266,332 KB
最終ジャッジ日時 2023-08-01 18:49:55
合計ジャッジ時間 9,825 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,628 KB
testcase_01 AC 45 ms
49,964 KB
testcase_02 AC 45 ms
49,620 KB
testcase_03 AC 45 ms
47,984 KB
testcase_04 AC 44 ms
49,616 KB
testcase_05 AC 46 ms
51,656 KB
testcase_06 AC 58 ms
55,420 KB
testcase_07 AC 61 ms
55,492 KB
testcase_08 AC 58 ms
48,328 KB
testcase_09 AC 55 ms
52,508 KB
testcase_10 AC 54 ms
54,224 KB
testcase_11 AC 51 ms
50,008 KB
testcase_12 AC 66 ms
55,200 KB
testcase_13 AC 48 ms
51,708 KB
testcase_14 AC 66 ms
56,784 KB
testcase_15 AC 49 ms
49,952 KB
testcase_16 AC 65 ms
55,120 KB
testcase_17 AC 51 ms
54,108 KB
testcase_18 AC 46 ms
49,636 KB
testcase_19 AC 46 ms
49,524 KB
testcase_20 AC 47 ms
51,672 KB
testcase_21 AC 48 ms
49,924 KB
testcase_22 AC 54 ms
58,472 KB
testcase_23 AC 51 ms
52,100 KB
testcase_24 AC 50 ms
54,280 KB
testcase_25 AC 76 ms
59,952 KB
testcase_26 AC 65 ms
55,460 KB
testcase_27 AC 52 ms
49,632 KB
testcase_28 AC 185 ms
190,712 KB
testcase_29 AC 130 ms
115,648 KB
testcase_30 WA -
testcase_31 AC 61 ms
62,680 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 151 ms
131,112 KB
testcase_35 AC 191 ms
190,344 KB
testcase_36 AC 245 ms
190,768 KB
testcase_37 AC 138 ms
85,604 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 194 ms
190,672 KB
testcase_42 AC 152 ms
113,172 KB
testcase_43 WA -
testcase_44 AC 108 ms
77,672 KB
testcase_45 AC 170 ms
131,148 KB
testcase_46 WA -
testcase_47 AC 394 ms
266,332 KB
testcase_48 AC 89 ms
55,004 KB
testcase_49 AC 101 ms
55,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
 
public class Main {
    static int n,m,k;
    static ArrayList<Music> li;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long mod = (long)Math.pow(10,9)+7;
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        li = new ArrayList<>();
        for(int i = 0; i < m; i++){
            int p = sc.nextInt()-1;
            int q = sc.nextInt()-1;
            int c = sc.nextInt();
            li.add(new Music(p,q,c));
        }
        Collections.sort(li);
        long[][][] dp = new long[300][n+1][k+2];
        for(int i = 0; i < 300; i++){
            dp[i][1][0] = 1;
        }
        for(int i = 2; i <= n; i++){
            for(Music m : li){
                for(int j = k-m.c; j >= 0; j--){
                    dp[m.q][i][j+m.c] += dp[m.p][i-1][j];
                }
            }
        }
        long ans = 0;
        for(int i = 0; i < 300; i++){
            ans += dp[i][n][k];
            ans %= mod;
        }
        System.out.println(ans);
    }
}

class Music implements Comparable<Music>{
    int p,q,c;
    public Music(int p, int q, int c){
        this.p = p;
        this.q = q;
        this.c = c;
    } 
    
    public int compareTo(Music m){
        if(this.c > m.c){
            return -1;
        }else if(this.c < m.c){
            return 1;
        }else{
            return 0;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}
0