繁华模拟赛 Evensgn的债务

时间:2023-03-09 14:43:07
繁华模拟赛 Evensgn的债务

繁华模拟赛 Evensgn的债务

繁华模拟赛 Evensgn的债务

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#define ll int
using namespace std;
const int maxn = ;
ll read(){
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';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 = ;i <= m;i++){
a = read();
b = read();
c = read();
v[a] -= c;
v[b] += c;
}
for(int i = ;i <= n;i++){
if(v[i] >= ) sum += v[i];
else sum -= v[i];
}
sum >>= ;
cout<<sum;
return ;
}