Cod sursa(job #1297935)

Utilizator serban_ioan97Ciofu Serban serban_ioan97 Data 22 decembrie 2014 14:00:36
Problema Distante Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <cstdio>
#define nmax 50005

using namespace std;

int dist[nmax];
int i, m, n, x, y, cost, okay, tests, source;

int main()
{
    freopen("distante.in", "rt", stdin);
    freopen("distante.out", "wt", stdout);

    scanf("%d", &tests);
    for(int qq=1; qq<=tests; ++qq)
    {
        okay=1;
        scanf("%d%d%d", &n, &m, &source);

        for(i=1; i<=n; ++i) scanf("%d", &dist[i]);

        for(i=1; i<=m; ++i)
        {
            scanf("%d%d%d", &x, &y, &cost);
            if(dist[y]>dist[x]+cost) okay=0;
        }

        if(okay) printf("DA\n");
        else printf("NU\n");
    }
    return 0;
}