結果
問題 | No.2854 -1 Subsequence |
ユーザー | ku_senjan |
提出日時 | 2024-08-25 13:48:03 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 571 bytes |
コンパイル時間 | 3,337 ms |
コンパイル使用メモリ | 278,564 KB |
実行使用メモリ | 15,964 KB |
最終ジャッジ日時 | 2024-08-25 13:48:20 |
合計ジャッジ時間 | 6,874 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 79 ms
12,944 KB |
testcase_02 | WA | - |
testcase_03 | AC | 46 ms
8,704 KB |
testcase_04 | WA | - |
testcase_05 | AC | 58 ms
10,300 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 14 ms
6,940 KB |
testcase_09 | AC | 63 ms
11,008 KB |
testcase_10 | AC | 102 ms
15,856 KB |
testcase_11 | AC | 104 ms
15,568 KB |
testcase_12 | AC | 103 ms
15,744 KB |
testcase_13 | AC | 100 ms
15,756 KB |
testcase_14 | AC | 106 ms
15,700 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 97 ms
15,696 KB |
testcase_21 | WA | - |
testcase_22 | AC | 110 ms
15,668 KB |
testcase_23 | AC | 1 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,940 KB |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 2 ms
6,940 KB |
testcase_31 | AC | 1 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,944 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 1 ms
6,944 KB |
testcase_38 | AC | 2 ms
6,940 KB |
testcase_39 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr ll INF = 1LL<<60; int main(){ int N; cin >> N; vector<ll> A(N); for(int i=0; i<N; i++){ cin >> A[i]; } vector dp(N+1, vector<ll>(2, -INF)); dp[1][0] = -A[0]; for(int i=1; i<N; i++){ for(int j=0; j<2; j++){ if(dp[i][j]==-INF) continue; dp[i+1][j] = max(dp[i+1][j], dp[i][j]); if(j==0){ dp[i+1][1] = max(dp[i+1][1], dp[i][0] + A[i]); }else{ dp[i+1][0] = max(dp[i+1][1-j], dp[i][1] - A[i]); } } } cout << max(dp[N][0], dp[N][1]) << endl; return 0; }