結果

問題 No.2321 Continuous Flip
ユーザー lgswdnlgswdn
提出日時 2023-06-03 14:39:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,813 bytes
コンパイル時間 2,169 ms
コンパイル使用メモリ 206,156 KB
実行使用メモリ 31,444 KB
最終ジャッジ日時 2023-08-28 07:52:57
合計ジャッジ時間 27,078 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,864 KB
testcase_01 AC 4 ms
9,596 KB
testcase_02 AC 4 ms
9,592 KB
testcase_03 AC 4 ms
9,528 KB
testcase_04 AC 645 ms
23,244 KB
testcase_05 AC 717 ms
27,096 KB
testcase_06 AC 736 ms
27,480 KB
testcase_07 AC 980 ms
27,292 KB
testcase_08 AC 584 ms
24,360 KB
testcase_09 AC 1,104 ms
27,812 KB
testcase_10 AC 1,361 ms
31,044 KB
testcase_11 AC 914 ms
26,676 KB
testcase_12 AC 894 ms
26,876 KB
testcase_13 AC 701 ms
24,352 KB
testcase_14 AC 988 ms
26,656 KB
testcase_15 AC 742 ms
23,444 KB
testcase_16 AC 644 ms
24,452 KB
testcase_17 AC 710 ms
27,744 KB
testcase_18 AC 836 ms
27,188 KB
testcase_19 AC 647 ms
24,364 KB
testcase_20 AC 803 ms
27,944 KB
testcase_21 AC 820 ms
26,616 KB
testcase_22 AC 744 ms
23,248 KB
testcase_23 AC 1,049 ms
31,444 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ac 1
#define wa 0
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

#define int long long
const int N=2e5+9,inf=2e18;
int n,m,d[N],ans,c;
vp e[N];

void dijkstra() {
  d[1]=0; rep(i,2,n+1) d[i]=inf;
  priority_queue<pii>q; q.push(pii(0,1));
  while(!q.empty()) {
    int u=q.top().se; q.pop();
    for(auto [v,w]:e[u]) if(d[v]>d[u]+w)
      d[v]=d[u]+w, q.push(pii(-d[v],v));
  }
}

signed main() {
  n=read(), m=read(), c=read();
  rep(i,1,n) {
    int a=read(); ans+=a;
    e[i].eb(i+1,a), e[i+1].eb(i,a);
  }
  rep(i,1,m) {
    int l=read(), r=read();
    e[l].eb(r+1,c), e[r+1].eb(l,c);
  }
  dijkstra();
  printf("%lld\n",ans-d[n+1]);
  return 0;
}
0