結果

問題 No.417 チューリップバブル
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-12-20 17:46:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,295 bytes
コンパイル時間 3,528 ms
コンパイル使用メモリ 147,176 KB
実行使用メモリ 5,048 KB
最終ジャッジ日時 2023-08-21 03:19:32
合計ジャッジ時間 16,557 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 6 ms
4,376 KB
testcase_33 AC 24 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n, m;
int u[220];
vector<pair<int, int> > dist[220];
int dp[220][2200];

void ki_dp(int s, int pa){ //今 親
	dp[s][0] = u[s]; //0秒でu[s];
	for (auto t : dist[s]){ //s -> t
 		if(s != t.fi && pa != t.fi){
 			ki_dp(t.fi, s);
 			for (int j = 0; j <= m; ++j){
 				for (int i = m; i >= 0; --i){
 					int cost = i + j + t.se * 2;
 					if(cost <= m){
 						dp[s][cost] = chmax(dp[s][cost], dp[s][i] + dp[t.fi][j]);
 					}
 				}
 			}
 		}
	}
}
int main(void){
	cin >> n >> m;
	rep(i, n) cin >> u[i];
	rep(i, n - 1){
		int a, b, c;
		cin >> a >> b >> c;
		dist[a].pb(mp(b, c));
		dist[b].pb(mp(a, c));
	}
	ki_dp(0, -1);
	int ans = 0;
	rep(i, m + 1){
		chmax(ans, dp[0][i]);
	}

	printf("%d\n", ans);
	return 0;
}
0