Pagini recente » Cod sursa (job #1510835) | Cod sursa (job #2728512) | Cod sursa (job #683357) | Cod sursa (job #2716255) | Cod sursa (job #1317738)
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("distante.in");
ofstream g("distante.out");
int d;
void rezolvare(int c)
{
int ok,cost;
long x,y,a[50000],n,m,i,s;
ok=1;
f>>n>>m>>s;
for(i=1;i<=n;i++)
f>>a[i];
if(a[s]!=0)
ok=0;
for(i=1;i<=m && ok==1;i++)
{
f>>x>>y>>cost;
if(a[x]+cost<a[y])
ok=0;
}
if(ok)
g<<"DA"<<endl;
else
g<<"NU"<<endl;
}
int main()
{
int c;
f>>d;
for(c=1;c<=d;c++)
rezolvare(c);
return 0;
}