結果

問題 No.417 チューリップバブル
ユーザー kzyKTkzyKT
提出日時 2016-08-26 23:30:29
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,539 bytes
コンパイル時間 1,279 ms
コンパイル使用メモリ 162,232 KB
実行使用メモリ 813,824 KB
最終ジャッジ日時 2024-04-25 21:52:24
合計ジャッジ時間 4,785 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int, int, int)’:
main.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
   36 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;
vector<P> v[200];
int d[2000001],a[200];

int dfs(int x, int p, int c, int t) {
  for(int i=200000-c; i>=t; i--) d[i+c]=max(d[i+c],d[i]+a[x]);
  rep(i,v[x].size()) {
    int y=v[x][i].F;
    if(y!=p) dfs(y,x,v[x][i].S,t+c);
  }
}

void Main() {
  int n,m;
  cin >> n >> m;
  rep(i,n) cin >> a[i];
  rep(i,n-1) {
    int x,y,z;
    cin >> x >> y >> z;
    v[x].pb(P(y,z));
    v[y].pb(P(x,z));
  }
  dfs(0,-1,0,0);
  int ans=0;
  rep(i,2000001) {
    if(i*2<=m) ans=max(ans,d[i]);
  }
  pr(ans);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}
0