結果

問題 No.1111 コード進行
ユーザー sca1l
提出日時 2020-07-19 15:13:08
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,384 bytes
コンパイル時間 2,488 ms
コンパイル使用メモリ 78,276 KB
実行使用メモリ 224,904 KB
最終ジャッジ日時 2024-12-16 05:54:20
合計ジャッジ時間 79,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 7 WA * 22 TLE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int[][] complexity = new int[301][301];
        for(int i=0; i<m; i++){
            int p = Integer.parseInt(sc.next());
            int q = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            complexity[p][q] = c;
        }
        
        int[][][] dp = new int[n][301][k+1];
        for(int i=1; i<=300; i++){
            dp[0][i][0] = 1;
        }
        for(int i=1; i<n-1; i++){
            for(int now=1; now<=300; now++){
                for(int j=0; j<k; j++){
                    for(int next=1; next<=300; next++){
                        int sum = j+complexity[now][next];
                        if(sum <= k){
                            dp[i][next][sum] += dp[i-1][now][j];
                            dp[i][next][sum] %= MOD;
                        }
                    }
                }
            }
        }
        
        int ans = 0;
        for(int i=1; i<=300; i++){
            ans += dp[n-2][i][k];
            ans %= MOD;
        }
        
        System.out.println(ans);
    }
}
0