There are multiple test cases.
For each test case:
The 1st line contains 3 integers n (2 ≤ n ≤ 10), m, t (1 ≤ t ≤ 1000000) indicating the number of rooms, the number of edges between rooms and the escape time.
The 2nd line contains 2 integers s and e, indicating the starting room and the exit.
The 3rd line contains n integers, the ith interger ji (1 ≤ ji ≤ 1000000) indicating the number of jewels in the ith room.
The next m lines, every line contains 3 integers a, b, c, indicating that there is a way between room a and room b and it will take c (1 ≤ c ≤ t) seconds.
For each test cases, you should print one line contains one integer the maximum number of jewels that LTR can take. If LTR can not reach the exit in time then output 0 instead.
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200001
#define mod 10007
#define eps 1e-9
int Num;
char CH[20];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=0,f=1;char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=0;if(!x){putchar(‘0‘);puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
//**************************************************************************************
struct node
{
int x,y;
};
int n,m,t;
int s,en;
int jew[15];
int vis[20][20];
int ans;
int g[20][20];
void init()
{
ans=0;
memset(jew,0,sizeof(jew));
memset(g,0,sizeof(g));
memset(vis,0,sizeof(vis));
}
void dfs(int po,int tt,int num)
{
if(po==en&&tt<=t)
ans=max(ans,num);
for(int i=0;i<n;i++)
{
if(!vis[po][i]&&g[po][i]&&tt+g[po][i]<=t)
{
int tmp=jew[i];
vis[po][i]=1;
jew[i]=0;
dfs(i,tt+g[po][i],num+tmp);
jew[i]=tmp;
vis[po][i]=0;
}
}
}
int main()
{
//freopen("test.txt","r",stdin);
while(scanf("%d%d%d",&n,&m,&t)!=EOF)
{
init();
s=read(),en=read();
for(int i=0;i<n;i++)
jew[i]=read();
for(int i=1;i<=m;i++)
{
int a=read(),b=read(),c=read();
g[a][b]=c,g[b][a]=c;
}
int tmp=jew[s];
jew[s]=0;
dfs(s,0,tmp);
printf("%d\n",ans);
}
}