結果
問題 | No.2321 Continuous Flip |
ユーザー | kotatsugame |
提出日時 | 2023-05-26 22:41:24 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 1,038 ms |
コンパイル使用メモリ | 78,668 KB |
実行使用メモリ | 20,156 KB |
最終ジャッジ日時 | 2023-08-26 12:49:27 |
合計ジャッジ時間 | 7,753 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
11,836 KB |
testcase_01 | AC | 4 ms
11,608 KB |
testcase_02 | AC | 4 ms
11,768 KB |
testcase_03 | AC | 4 ms
11,584 KB |
testcase_04 | WA | - |
testcase_05 | AC | 157 ms
18,896 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 | 155 ms
18,952 KB |
testcase_22 | WA | - |
testcase_23 | AC | 156 ms
19,008 KB |
testcase_24 | AC | 81 ms
20,156 KB |
testcase_25 | AC | 4 ms
11,756 KB |
testcase_26 | AC | 66 ms
18,776 KB |
testcase_27 | AC | 89 ms
18,824 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 131 ms
19,616 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 130 ms
19,572 KB |
ソースコード
#include<iostream> #include<vector> #include<queue> using namespace std; int N,M,C; int A[2<<17]; long S[2<<17]; vector<int>G[2<<17]; long dp[2<<17]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin>>N>>M>>C; for(int i=0;i<N;i++) { cin>>A[i]; S[i+1]=S[i]+A[i]; } for(int i=0;i<M;i++) { int l,r;cin>>l>>r; G[l-1].push_back(r); } priority_queue<pair<long,int> >Q; for(int i=0;i<=N;i++) { while(!Q.empty()&&Q.top().second<i)Q.pop(); if(!Q.empty())dp[i]=max(dp[i],2*S[i]+Q.top().first); if(i<N)dp[i+1]=max(dp[i+1],dp[i]); for(int r:G[i])Q.push(make_pair(dp[i]-S[r]-S[i]-C,r)); //cout<<dp[i]<<" "; } //cout<<endl; cout<<dp[N]<<endl; }