# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101523 | 2019-03-19T03:37:19 Z | rocketninja7 | Chase (CEOI17_chase) | C++14 | 124 ms | 10620 KB |
#include <cstdio> #include <vector> using namespace std; vector<int> adjList[100001]; long long int p[100001]; bool vis[100001]; long long int dp(int bread, int node){ if(bread==0){ return 0; } vis[node]=true; long long int ans=0; long long int temp=0; for(int i=0;i<adjList[node].size();i++){ if(!vis[adjList[node][i]]){ temp+=p[adjList[node][i]]; } } for(int i=0;i<adjList[node].size();i++){ if(!vis[adjList[node][i]]){ ans=max(ans, max(dp(bread, adjList[node][i]), dp(bread-1, adjList[node][i])+temp)); } } return ans; } int main(){ int n, v; scanf("%d%d", &n, &v); for(int i=1;i<n+1;i++){ scanf("%lld", &p[i]); } for(int i=0;i<n-1;i++){ int a, b; scanf("%d%d", &a, &b); adjList[a].push_back(b); adjList[b].push_back(a); } long long int ans=0; for(int i=1;i<n+1;i++){ for(int j=1;j<n+1;j++){ vis[j]=false; } ans=max(ans, dp(v, i)); if(n>1000){ break; } } printf("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2688 KB | Output is correct |
2 | Correct | 4 ms | 2688 KB | Output is correct |
3 | Correct | 4 ms | 2688 KB | Output is correct |
4 | Correct | 5 ms | 2688 KB | Output is correct |
5 | Correct | 4 ms | 2688 KB | Output is correct |
6 | Correct | 5 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2688 KB | Output is correct |
2 | Correct | 4 ms | 2688 KB | Output is correct |
3 | Correct | 4 ms | 2688 KB | Output is correct |
4 | Correct | 5 ms | 2688 KB | Output is correct |
5 | Correct | 4 ms | 2688 KB | Output is correct |
6 | Correct | 5 ms | 2688 KB | Output is correct |
7 | Incorrect | 25 ms | 2688 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 124 ms | 10620 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 2688 KB | Output is correct |
2 | Correct | 4 ms | 2688 KB | Output is correct |
3 | Correct | 4 ms | 2688 KB | Output is correct |
4 | Correct | 5 ms | 2688 KB | Output is correct |
5 | Correct | 4 ms | 2688 KB | Output is correct |
6 | Correct | 5 ms | 2688 KB | Output is correct |
7 | Incorrect | 25 ms | 2688 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |