Cod sursa(job #583716)

Utilizator paul_gabryelPaul Buda paul_gabryel Data 22 aprilie 2011 02:41:32
Problema Distante Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.6 kb

#include <cstdio>
#include <fstream>

using namespace std;

#define N 50005

int v[N];

int main ()
{

    int m,n,t,s,x,y,c;
    ifstream in ("distante.in");
    freopen ("distante.out","w",stdout);
    for(in>>t;t;--t){
        in>>n>>m>>s;
        for(int i=1;i<=n;++i)
            in>>v[i];
        bool vrf=true;
        for(;m;--m){
            in>>x>>y>>c;
            if(vrf)
            if( v[y]>v[x]+c || v[x]>v[y]+c ){
                vrf=false;
                printf("NU\n");
            }
        }
        if(vrf)
            printf("DA\n");
    }

return 0;}