結果

問題 No.1117 数列分割
ユーザー QDSNQDSN
提出日時 2020-07-19 20:32:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 1,523 ms
コンパイル使用メモリ 169,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-09 19:03:17
合計ジャッジ時間 2,710 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 11 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 7 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 19 ms
5,376 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 18 ms
5,376 KB
testcase_25 AC 17 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k, m;
    cin >> n >> k >> m;
    vector<ll> a(n), rui(n + 1, 0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        rui[i + 1] = rui[i] + a[i];
    }
    vector<ll> dp(n + 1, 0);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(i - j >= 0) {
                dp[i + 1] =
                    max(dp[i + 1], dp[i - j] + abs(rui[i + 1] - rui[i - j]));
            }
        }
    }
    cout << dp.back() << endl;
}
0