結果
問題 | No.1117 数列分割 |
ユーザー | QDSN |
提出日時 | 2020-07-19 21:31:43 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 850 bytes |
コンパイル時間 | 1,672 ms |
コンパイル使用メモリ | 173,224 KB |
実行使用メモリ | 23,168 KB |
最終ジャッジ日時 | 2024-05-09 20:35:40 |
合計ジャッジ時間 | 7,741 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
10,752 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 32 ms
8,576 KB |
testcase_04 | AC | 212 ms
8,064 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 395 ms
7,808 KB |
testcase_09 | AC | 33 ms
5,376 KB |
testcase_10 | AC | 498 ms
7,808 KB |
testcase_11 | TLE | - |
testcase_12 | AC | 1,005 ms
23,168 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
#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<vector<ll>> dp(n + 1, vector<ll>(k + 1, LLONG_MIN / 3)); dp[0][0] = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < min(m, ll(i) + 1); j++) { for(int l = 0; l < k; l++) { if(i - j >= 0) { dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i - j][l] + abs(rui[i + 1] - rui[i - j])); } else { break; } } } } cout << dp[n][k] << endl; }