結果

問題 No.1111 コード進行
ユーザー ks2mks2m
提出日時 2020-07-10 22:02:10
言語 Java19
(openjdk 21)
結果
AC  
実行時間 745 ms / 2,000 ms
コード長 1,679 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 75,888 KB
実行使用メモリ 266,104 KB
最終ジャッジ日時 2023-08-01 17:57:27
合計ジャッジ時間 11,006 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,048 KB
testcase_01 AC 44 ms
49,048 KB
testcase_02 AC 42 ms
47,284 KB
testcase_03 AC 42 ms
49,264 KB
testcase_04 AC 44 ms
49,104 KB
testcase_05 AC 44 ms
51,204 KB
testcase_06 AC 67 ms
56,256 KB
testcase_07 AC 62 ms
55,324 KB
testcase_08 AC 60 ms
50,632 KB
testcase_09 AC 59 ms
52,724 KB
testcase_10 AC 56 ms
54,876 KB
testcase_11 AC 51 ms
49,212 KB
testcase_12 AC 75 ms
55,212 KB
testcase_13 AC 49 ms
51,700 KB
testcase_14 AC 98 ms
58,000 KB
testcase_15 AC 49 ms
49,308 KB
testcase_16 AC 94 ms
57,592 KB
testcase_17 AC 49 ms
54,012 KB
testcase_18 AC 42 ms
49,204 KB
testcase_19 AC 44 ms
49,324 KB
testcase_20 AC 47 ms
51,336 KB
testcase_21 AC 47 ms
49,268 KB
testcase_22 AC 54 ms
58,380 KB
testcase_23 AC 55 ms
52,608 KB
testcase_24 AC 51 ms
53,680 KB
testcase_25 AC 103 ms
62,028 KB
testcase_26 AC 73 ms
55,432 KB
testcase_27 AC 51 ms
49,496 KB
testcase_28 AC 215 ms
188,452 KB
testcase_29 AC 137 ms
113,588 KB
testcase_30 AC 181 ms
131,424 KB
testcase_31 AC 59 ms
61,940 KB
testcase_32 AC 221 ms
131,664 KB
testcase_33 AC 193 ms
92,864 KB
testcase_34 AC 150 ms
132,832 KB
testcase_35 AC 206 ms
188,356 KB
testcase_36 AC 408 ms
186,796 KB
testcase_37 AC 171 ms
85,796 KB
testcase_38 AC 143 ms
78,232 KB
testcase_39 AC 261 ms
131,396 KB
testcase_40 AC 282 ms
148,176 KB
testcase_41 AC 207 ms
192,136 KB
testcase_42 AC 200 ms
113,712 KB
testcase_43 AC 197 ms
94,620 KB
testcase_44 AC 122 ms
78,432 KB
testcase_45 AC 193 ms
131,876 KB
testcase_46 AC 92 ms
54,944 KB
testcase_47 AC 745 ms
266,104 KB
testcase_48 AC 148 ms
57,504 KB
testcase_49 AC 111 ms
57,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		int max = 301;
		List<List<Obj>> list = new ArrayList<>(max);
		for (int i = 0; i < max; i++) {
			list.add(new ArrayList<>());
		}
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int p = Integer.parseInt(sa[0]);
			Obj o = new Obj();
			o.q = Integer.parseInt(sa[1]);
			o.c = Integer.parseInt(sa[2]);
			list.get(p).add(o);
			set.add(p);
		}
		br.close();

		int mod = 1000000007;
		// x個、最後がy、複雑度z
		long[][][] dp = new long[n][max][k + 1];
		for (int y : set) {
			dp[0][y][0] = 1;
		}
		for (int x = 0; x < n - 1; x++) {
			for (int y : set) {
				for (Obj next : list.get(y)) {
					for (int z = 0; z <= k; z++) {
						if (z + next.c <= k) {
							dp[x + 1][next.q][z + next.c] += dp[x][y][z];
							dp[x + 1][next.q][z + next.c] %= mod;
						}
					}
				}
			}
//			for (int y = 0; y < 5; y++) {
//				for (int z = 0; z <= k; z++) {
//					System.out.print(dp[x + 1][y][z] + "\t");
//				}
//				System.out.println();
//			}
//			System.out.println();
		}

		long ans = 0;
		for (int y = 0; y < max; y++) {
			ans += dp[n - 1][y][k];
		}
		ans %= mod;
		System.out.println(ans);
	}

	static class Obj {
		int q, c;
	}
}
0