Submission #00165


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>Point;
int maxim=0;
int main(){
int n,m;
int k,z;
int data[100005]={0};
vector<P>node[100005];
cin>>n>>m;
cin>>k>>z;
for(int i=1;i<n-1;i++){
cin>>data[i];
}
for(int i=0;i<m;i++){
int a,b,c;
cin>>a>>b>>c;
node[a].push_back(P(b,c));
node[b].push_back(P(a,c));
}
queue<Point>que;
que.push(Point(0,P(0,0)));
while(!que.empty()){
Point now=que.front();que.pop();
int homo=now.first;
int cost=now.second.first;
int pos=now.second.second;
if(pos==n-1){
maxim=max(maxim,homo);
}
for(int i=0;i<node[pos].size();i++){
int next=node[pos][i].first;
int ncost=node[pos][i].second+cost;
int nhomo=data[next]+homo;
if(ncost<k){
que.push(Point(nhomo,P(ncost,next)));
}
}
}
cout<<maxim<<endl;
return(0);
}

ステータス

項目 データ
問題 0005 - れんさん退治
ユーザー名 波紋疾走
投稿日時 2017-08-08 11:44:17
言語 C++11
状態 Wrong Answer
得点 0
ソースコード長 971 Byte
最大実行時間 19 ms
最大メモリ使用量 3356 KB

セット

セット 得点 Cases
1 ALL 0 / 80 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input1.txt WA 13 ms 3168 KB
1
input2.txt WA 19 ms 3356 KB
1
input3.txt AC 15 ms 3292 KB
1