Mai intai trebuie sa te autentifici.
Cod sursa(job #862389)
Utilizator | Data | 22 ianuarie 2013 17:49:30 | |
---|---|---|---|
Problema | Distante | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.73 kb |
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;
#define maxn 1001
int tst ;
int n, m, sursa ;
int dist[maxn] ;
int main()
{
freopen("distante.in", "r", stdin);
freopen("distante.out", "w", stdout);
scanf("%d", &tst);
while( tst )
{
scanf("%d%d%d", &n, &m, &sursa);
for(int i = 1; i <= n; ++i )
scanf("%d", &dist[i]);
bool ok = true ;
for(int i = 1; i <= m; ++i )
{
int a, b, cost ;
scanf("%d%d%d", &a, &b, &cost);
if( dist[b] > dist[a] + cost )
{
ok = false ;
break ;
}
}
if( ok == true )
printf("DA\n");
else
printf("NU\n");
--tst ;
}
return 0 ;
}