提出 #777621


ソースコード 拡げる

#include<iostream>
#include<vector>
#include<map>
#include<queue>
#define INF 1000000007
#define int long long
#define ll long long
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
namespace Dikstra{
    struct Node{
        int pos,prev;
		ll cost;
        vector<int> to;
        vector<ll> to_cost;
        static bool Graeter(const Node& a,const Node& b){return a.cost>b.cost;}
        static bool Less(const Node& a,const Node& b){return a.cost<b.cost;}
    };
    class Greater{public: bool operator()(const Node& a,const Node& b){return a.cost>b.cost;}};
    class Less   {public: bool operator()(const Node& a,const Node& b){return a.cost<b.cost;}};
    class Dikstra{
    public:
        int n;
        vector<Node> nodes;
        Dikstra(void){}
        Dikstra(int n_){n=n_; nodes.resize(n);init();}
        void init(){REP(i,n)nodes[i].pos=i,nodes[i].cost=INF,nodes[i].prev=INF;}
        void addEdge(int x,int y,ll cost_){
            nodes[x].to.push_back(y);
            nodes[x].to_cost.push_back(cost_);
        }
        vector<ll> culCost(int start){
            nodes[start].cost=0;
            priority_queue<Node,vector<Node>,Greater> Q;
            Q.push(nodes[start]);
            while(!Q.empty()){
                Node current = Q.top();Q.pop();
                REP(i,current.to.size()){
                    Node& next = nodes[current.to[i]];
                    if (next.cost > current.cost + current.to_cost[i]){
                        next.cost = current.cost + current.to_cost[i];
                        next.prev = current.pos;
                        Q.push(next);
                    }
                }
            }
            vector<ll> res(n);
            REP(i,n){res[i]=nodes[i].cost;}
            return res;
        }
    };
}


signed main(){
	int N,M;
	ll T;
	cin>>N>>M>>T;
	vector<ll> A(N,0);
	Dikstra::Dikstra dik(N);
	Dikstra::Dikstra rdik(N);

	REP(i,N) cin>>A[i];
	REP(i,M){
		int a,b;ll c;cin>>a>>b>>c;a--;b--;
		dik.addEdge(a,b,c);
		rdik.addEdge(b,a,c);
	}
	vector<ll> res =dik.culCost(0);
	vector<ll> rres=rdik.culCost(0);
	ll ma=0;
	REP(i,N){
// 		cout<<res[i] << " "<<rres[i]<<endl;
 		if(T<res[i]+rres[i]) continue;
		ma = max(ma,A[i]*(T-res[i]-rres[i]));
	}
	cout<<ma<<endl;
	return 0;
}

提出情報

提出日時
問題 D - トレジャーハント
ユーザ ish_774
言語 C++14 (GCC 5.4.1)
得点 100
コード長 2339 Byte
結果 AC
実行時間 363 ms
メモリ 29184 KiB

ジャッジ結果

セット名 Sample Subtask1 All
得点 / 配点 0 / 0 50 / 50 50 / 50
結果
AC × 3
AC × 20
AC × 42
セット名 テストケース
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_12.txt, 10_rand_13.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 30_max_05.txt, 30_max_06.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
ケース名 結果 実行時間 メモリ
00_example_01.txt AC 6 ms 256 KiB
00_example_02.txt AC 4 ms 256 KiB
00_example_03.txt AC 4 ms 256 KiB
10_rand_01.txt AC 21 ms 3200 KiB
10_rand_02.txt AC 69 ms 5108 KiB
10_rand_03.txt AC 27 ms 3840 KiB
10_rand_04.txt AC 11 ms 1792 KiB
10_rand_05.txt AC 32 ms 5248 KiB
10_rand_06.txt AC 34 ms 6656 KiB
10_rand_07.txt AC 50 ms 9984 KiB
10_rand_08.txt AC 21 ms 3840 KiB
10_rand_09.txt AC 43 ms 8576 KiB
10_rand_10.txt AC 13 ms 2176 KiB
10_rand_12.txt AC 134 ms 6304 KiB
10_rand_13.txt AC 126 ms 6348 KiB
30_max_01.txt AC 291 ms 12440 KiB
30_max_02.txt AC 345 ms 15664 KiB
30_max_03.txt AC 223 ms 10352 KiB
30_max_04.txt AC 295 ms 25088 KiB
30_max_05.txt AC 321 ms 25088 KiB
30_max_06.txt AC 311 ms 25088 KiB
40_corner_01.txt AC 322 ms 29184 KiB
40_corner_02.txt AC 329 ms 29184 KiB
40_corner_03.txt AC 343 ms 29184 KiB
40_corner_04.txt AC 363 ms 29184 KiB
50_small_01.txt AC 7 ms 384 KiB
50_small_02.txt AC 4 ms 256 KiB
50_small_03.txt AC 4 ms 256 KiB
50_small_04.txt AC 5 ms 256 KiB
50_small_05.txt AC 9 ms 512 KiB
50_small_06.txt AC 7 ms 384 KiB
50_small_07.txt AC 4 ms 256 KiB
50_small_08.txt AC 4 ms 256 KiB
50_small_09.txt AC 6 ms 384 KiB
50_small_10.txt AC 5 ms 256 KiB
60_hand_01.txt AC 4 ms 256 KiB
60_hand_02.txt AC 4 ms 256 KiB
60_hand_03.txt AC 4 ms 256 KiB
60_hand_04.txt AC 4 ms 256 KiB
70_max_01.txt AC 65 ms 4096 KiB
70_max_02.txt AC 65 ms 3968 KiB
70_max_03.txt AC 65 ms 4096 KiB