Let's Go Green UVALive
来源:互联网 发布:淘宝轮毂 编辑:程序博客网 时间:2024/05/19 06:16
Let’s Go Green 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;}
阅读全文
0 0
- Let's Go Green UVALive
- Let's Go Green UVALive
- UVALive 6039 Let's Go Green
- UVALive 6039 Let's Go Green (贪心)
- Let's GO GO GO
- 坚定不移,let's go--------
- 好玩,Let's Go.....
- OK,let's go!
- Let`s go
- Let's go
- Let's go!!!
- OpenImage,let's go.
- Let's Go!
- emwin,Let's Go!!!
- Let's go!
- let's go!
- Let‘s go!
- OK ,Let's go...
- .net操作AD域
- LUXAND人脸识别(linux版本)
- hihocoder #1040 : 矩形判断
- HTTP1.0、HTTP1.1 和 HTTP2.0 的区别
- Spring 技术总结
- Let's Go Green UVALive
- Mysql基本语句操作(二)---一对多的实现和关联语句的用法
- vue页面跳转拦截器
- Linux下C++编程(二)----vim简单使用
- Chrome 开发者工具的错误与调试
- 关于js接收后台时间戳转换成时间问题
- scrapy-redis集成scrapy-splash使用教程
- 图像特征的特点及其常用的特征提取与匹配方法
- TP语法