結果
問題 | No.417 チューリップバブル |
ユーザー | 👑 horiesiniti |
提出日時 | 2016-06-29 09:03:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,106 bytes |
コンパイル時間 | 989 ms |
コンパイル使用メモリ | 71,244 KB |
実行使用メモリ | 4,664 KB |
最終ジャッジ日時 | 2023-09-02 08:34:57 |
合計ジャッジ時間 | 5,804 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 6 ms
4,380 KB |
testcase_09 | AC | 12 ms
4,376 KB |
testcase_10 | AC | 16 ms
4,380 KB |
testcase_11 | AC | 67 ms
4,384 KB |
testcase_12 | AC | 66 ms
4,384 KB |
testcase_13 | AC | 26 ms
4,376 KB |
testcase_14 | AC | 106 ms
4,380 KB |
testcase_15 | AC | 8 ms
4,380 KB |
testcase_16 | AC | 8 ms
4,384 KB |
testcase_17 | AC | 56 ms
4,380 KB |
testcase_18 | AC | 57 ms
4,460 KB |
testcase_19 | AC | 57 ms
4,380 KB |
testcase_20 | WA | - |
testcase_21 | AC | 219 ms
4,664 KB |
testcase_22 | WA | - |
testcase_23 | AC | 217 ms
4,396 KB |
testcase_24 | AC | 2 ms
4,492 KB |
testcase_25 | AC | 220 ms
4,412 KB |
testcase_26 | AC | 21 ms
4,412 KB |
testcase_27 | AC | 153 ms
4,380 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 219 ms
4,416 KB |
testcase_31 | AC | 218 ms
4,616 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 45 ms
4,380 KB |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
コンパイルメッセージ
main.cpp: In function ‘void f(int, int)’: main.cpp:24:9: warning: ‘void* memcpy(void*, const void*, size_t)’ writing 8004 bytes into a region of size 8000 overflows the destination [-Wstringop-overflow=] memcpy(temp,dp[now],sizeof(dp[now])); ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<iostream> #include<map> #include<algorithm> #include<string.h> const int LIMITM=2000; const int LIMITN=100; int dp[LIMITN][LIMITM+1]; std::map<int,int> tree[LIMITN]; int taxes[LIMITN]; int n,m; void f(int oya,int now){ memset(dp[now],0,sizeof(dp[now])); std::map<int,int>::iterator it; for(it=tree[now].begin();it!=tree[now].end();it++){ int next=(*it).first; int time=(*it).second*2; if(oya==next){ continue; } f(now,next); int temp[LIMITM]; memcpy(temp,dp[now],sizeof(dp[now])); for(int i=0;i+time<=m;i++){ for(int j=0;j+i+time<=m;j++){ int nextTime=j+i+time; int nextTax=dp[now][i]+dp[next][j]; temp[nextTime]=std::max(temp[nextTime],nextTax); } } memcpy(dp[now],temp,sizeof(temp)); } for(int i=0;i<=m;i++){ dp[now][i]+=taxes[now]; } } int main(){ scanf("%d %d",&n,&m); for(int i=0;i<n;i++){ scanf("%d",&taxes[i]); } for(int i=0;i<n-1;i++){ int a,b,c; scanf("%d %d %d",&a,&b,&c); tree[a][b]=c; tree[b][a]=c; } f(-1,0); int ans=0; for(int i=0;i<=m;i++){ ans=std::max(ans,dp[0][i]); } printf("%d\n",ans); }