Let's Go Green UVALive - 6039
2017-07-28 09:30
549 查看
Let’s Go Green UVALive - 6039
题目链接:https://cn.vjudge.net/problem/UVALive-6039
题目链接:https://cn.vjudge.net/problem/UVALive-6039
#include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <vector> using namespace std; vector<int> q[100010]; int main(){ int t; scanf("%d",&t); int tt=1; while(t--){ for (int i=0;i<100010;i++){ q[i].clear(); } int n; scanf("%d",&n); for (int i=1;i<n;i++){ int a,b,c; scanf("%d%d%d",&a,&b,&c); q[a].push_back(c); q[b].push_back(c); } int sum=0; for (int i=1;i<=n;i++){ sort(q[i].begin(),q[i].end()); int s=q[i][q[i].size()-1]; int ss=0; for (int j=0;j<(int)(q[i].size()-1);j++){ ss+=q[i][j]; } if (s>=ss){ sum+=(s-ss); } else{ if ((ss+s)%2!=0){ sum++; } } } printf("Case #%d: %d\n",tt++,sum/2); } return 0; }
相关文章推荐
- Let's Go Green UVALive - 6039题解 思维图论
- UVALive - 6039 Let's Go Green
- UVALive 6459 Infinite Go (模拟,搜索)
- UVALive 6188 (LA 6188) Let There Be Light 计算几何
- UVALive 6531 Go up the ultras 单调栈+RMQ
- UVALive 6531 Go up the ultras 单调栈+RMQ
- UVALive - 6039
- UvaLive 6531 Go up the ultras DP+RMQ
- UVALive2287 POJ1047 HDU1313 ZOJ1073 Round and Round We Go【大数+数学计算+水题】
- UVALive - 6039
- UVaLive ( LA ) 3516 - Exploring Pyramids (DP 递推)
- 简单几何(判断矩形的位置) UVALive 7070 The E-pang Palace(14广州B)
- UVALIVE 3523(双连通分量+二分图染色)
- UVALive - 6575 Odd and Even Zeroes 数位dp+找规律
- G - Meeting Room Arrangement UVALive - 6606——动态规划
- UVALive 7270 Osu! Master(简单水题)
- HDU 1824 Let's go home (2-SAT)
- UVALive 7512 November 11th(模拟, 思维)
- 2006 Asia - Kaohsiung Perfect Service 树形DP (uvaLive3685) ★
- UVALive - 7461 Separating Pebbles 凸包+线段相交