码迷,mamicode.com
首页 > 其他好文 > 详细

繁华模拟赛 Evensgn的债务

时间:2016-09-24 23:39:20      阅读:351      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

技术分享

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#define ll int
using namespace std;
const int maxn = 1000005;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<0||ch>9){if(ch==-)f=-1;ch=getchar();}
    while(ch>=0&&ch<=9){x=x*10+ch-0;ch=getchar();}
    return x*f;
}
int v[maxn],sum;
int n,m,a,b,c;
int main(){
    freopen("debt.in","r",stdin);
    freopen("debt.out","w",stdout);
    n = read();
    m = read();
    for(int i = 1;i <= m;i++){
        a = read();
        b = read();
        c = read();
        v[a] -= c;
        v[b] += c;
    }
    for(int i = 1;i <= n;i++){
        if(v[i] >= 0) sum += v[i];
        else sum -= v[i];
    }
    sum >>= 1;
    cout<<sum;
    return 0;
}

 

繁华模拟赛 Evensgn的债务

标签:

原文地址:http://www.cnblogs.com/hyfer/p/5904432.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!