hiho week 109 register

Ended

Participants:438

Verdict:Accepted
Score:100 / 100
Submitted:2016-08-06 16:23:25

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int>> tree;
vector<pair<int, int>> value;
set<pair<int, int>> edges;
vector<pair<ll, ll>> res;
bool cmp(pair<ll, ll> p1, pair<ll, ll> p2){
    return p1.second > p2.second;
}
void dfs(int x){
    if(tree[x].size() == 0){
        res[x] = value[x];
        return;
    }
    ll wallet = 200000000;
    ll minWallet = 200000000;
    for(int i = 0; i < tree[x].size(); i++){
        dfs(tree[x][i]);
    }
    vector<pair<ll, ll>> tmp;
    for(int i = 0; i < tree[x].size(); i++){
        tmp.push_back(res[tree[x][i]]);
    }
    sort(tmp.begin(), tmp.end(), cmp);
    wallet = wallet - value[x].first;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX