日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

zoj 3620 Escape Time II

發(fā)布時間:2024/1/17 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zoj 3620 Escape Time II 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4744

Escape Time II
Time Limit: 2 Seconds ???? Memory Limit: 65536 KB

There is a fire in LTR ’ s home again. The fire can destroy all the things in t seconds, so LTR has to escape in t seconds. But there are some jewels in LTR ’ s rooms, LTR love jewels very much so he wants to take his jewels as many as possible before he goes to the exit. Assume that the ith room has ji jewels. At the beginning LTR is in room s, and the exit is in room e.

Your job is to find a way that LTR can go to the exit in time and take his jewels as many as possible.

Input

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.

Output

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.

Sample Input

3 3 5 0 2 10 10 10 0 1 1 0 2 2 1 2 3 5 7 9 0 3 10 20 20 30 20 0 1 2 1 3 5 0 3 3 2 3 2 1 2 5 1 4 4 3 4 2

Sample Output

30 80 #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxx = 20; int Edge[maxx][maxx]; int val[maxx]; bool vis[maxx]; int big = 0,e,n,t; void dfs(int s, int num,int ju) {if(num>t) return;if(s == e)if(ju > big && num<=t)big = ju;vis[s] = true;for(int i=0;i<n;i++){if(i!=s && Edge[s][i]<1e8 && !vis[i]){dfs(i,num + Edge[s][i],ju + val[i]);}}vis[s] = false;} void Floyd() {for(int i=0; i<n;i++)for(int j=0; j<n; j++)for(int k=0; k<n; k++)if(Edge[j][i] + Edge[i][k] < Edge[j][k])Edge[j][k] = Edge[j][i] + Edge[i][k]; } int main() {int m;int s;while(~scanf("%d %d %d",&n,&m,&t)){memset(Edge,0x6,sizeof(Edge));memset(val,0,sizeof(val));memset(vis,0,sizeof(vis));scanf("%d %d",&s,&e);for(int i=0;i<n;i++)scanf("%d",&val[i]);for(int i=1;i<=m;i++){int u,v,w;scanf("%d %d %d",&u,&v,&w);Edge[u][v] = Edge[v][u] = w;}Floyd();big = 0;vis[s] = true;dfs(s,0,val[s]);printf("%d\n",big);}return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/cancangood/p/3946203.html

總結(jié)

以上是生活随笔為你收集整理的zoj 3620 Escape Time II的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。