結果

問題 No.2321 Continuous Flip
ユーザー kotatsugamekotatsugame
提出日時 2023-05-26 22:51:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 79,752 KB
実行使用メモリ 29,648 KB
最終ジャッジ日時 2023-08-26 13:06:56
合計ジャッジ時間 7,355 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,756 KB
testcase_01 AC 3 ms
9,532 KB
testcase_02 AC 2 ms
9,612 KB
testcase_03 AC 2 ms
9,596 KB
testcase_04 WA -
testcase_05 AC 157 ms
22,476 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 154 ms
22,184 KB
testcase_22 WA -
testcase_23 AC 154 ms
22,156 KB
testcase_24 AC 95 ms
21,388 KB
testcase_25 AC 3 ms
9,524 KB
testcase_26 AC 78 ms
19,280 KB
testcase_27 AC 80 ms
20,308 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 158 ms
29,216 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 154 ms
28,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M,C;
int A[2<<17];
vector<pair<int,int> >G[2<<17];
long dp[2<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M>>C;
	long sum=0;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		G[i].push_back(make_pair(i+1,A[i]));
		G[i+1].push_back(make_pair(i,A[i]));
		sum+=A[i];
	}
	for(int i=0;i<M;i++)
	{
		int l,r;cin>>l>>r;
		G[l-1].push_back(make_pair(r,C));
	}
	for(int i=1;i<=N;i++)dp[i]=9e18;
	priority_queue<pair<long,int> >Q;
	Q.push(make_pair(0L,0));
	while(!Q.empty())
	{
		int u=Q.top().second;
		long c=-Q.top().first;
		Q.pop();
		if(dp[u]<c)continue;
		for(pair<int,int>e:G[u])
		{
			int v=e.first;
			long nc=c+e.second;
			if(dp[v]>nc)
			{
				dp[v]=nc;
				Q.push(make_pair(-nc,v));
			}
		}
	}
	cout<<sum-dp[N]<<endl;
}
0