| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 80158 | farukkastamonuda | Dostavljač (COCI18_dostavljac) | C++14 | 218 ms | 2988 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 505
#define mp make_pair
#define pb push_back
using namespace std;
int n,T,x,y,dp[li][li],A[li],en[li][li];
vector<int> v[li];
void dfs(int node,int ata){
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata) continue;
		dfs(go,node);
	}
	for(int i=0;i<(int)v[node].size();i++){
		int go=v[node][i];
		if(go==ata) continue;
		for(int k=T;k>=3;k--){
			for(int j=1;j+2<=k;j++){
				en[node][k]=max(en[node][k],en[node][k-j-2]+dp[go][j]);
			}
		}
		for(int k=T;k>=2;k--){
			for(int j=1;j+1<=k;j++){
				en[node][k]=max(en[node][k],dp[node][k-j-1]+en[go][j]);
			}
		}
		for(int k=T;k>=3;k--){
			for(int j=1;j+2<=k;j++){
				dp[node][k]=max(dp[node][k],dp[node][k-j-2]+dp[go][j]);
			}
		}
	}
	for(int j=T;j>=1;j--){
		dp[node][j]=max(dp[node][j],dp[node][j-1]+A[node]);
		en[node][j]=max(en[node][j],en[node][j-1]+A[node]);
	}
}
int main(){
	scanf("%d %d",&n,&T);
	for(int i=1;i<=n;i++) scanf("%d",&A[i]);
	for(int i=1;i<n;i++){
		scanf("%d %d",&x,&y);
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs(1,0);
	printf("%d\n",en[1][T]);
	return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
