[ create a new paste ] login | about

Link: http://codepad.org/r2VyoeXT    [ raw code | output | fork ]

C++, pasted on Dec 25:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
    int n, a, b, c[105], k;
    long m;

    cin >> n >> m;

    fill (c, c+n, 0);


    for(int i=0; i<m; i++)
    {
        cin >> a >> b;
        cin >> k;

        c[a] -= k;
        c[b] += k;
    }

    int ans = 0;

    for(int i=0; i<n; i++)
    {
        if(c[i]<0)
            continue;

        ans += c[i];

    }

    cout << ans;
}


Output:
1
Segmentation fault


Create a new paste based on this one


Comments: