Cod sursa(job #2478061)
Utilizator | Andrei Rebecca rebecca0312 | Data | 21 octombrie 2019 16:37:59 |
---|---|---|---|
Problema | Distante | Scor | 60 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.68 kb |
#include<cstdio>
#include<algorithm>
using namespace std;
const int NMAX=50005;
int dist[NMAX];
int main(){
freopen("distante.in","r",stdin);
freopen("distante.out","w",stdout);
int t,n,m,s;
scanf("%d", &t);
for(int k=1;k<=t;k++){
scanf("%d%d%d", &n, &m, &s);
for(int i=1;i<=n;i++)
scanf("%d", &dist[i]);
int ok=1;
for(int j=1;j<=m;j++){
int a,b,c;
scanf("%d%d%d", &a, &b, &c);
if(max(dist[a]-dist[b], dist[b]-dist[a])>c)
ok=0;
}
if(ok==0)
printf("NU\n");
else
printf("DA\n");
}
return 0;
}