結果
問題 | No.1117 数列分割 |
ユーザー | nanophoto12 |
提出日時 | 2020-07-25 10:24:46 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,403 bytes |
コンパイル時間 | 2,247 ms |
コンパイル使用メモリ | 203,000 KB |
実行使用メモリ | 47,084 KB |
最終ジャッジ日時 | 2023-09-09 06:31:19 |
合計ジャッジ時間 | 10,467 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,756 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 418 ms
11,080 KB |
testcase_04 | AC | 497 ms
11,020 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 3 ms
4,376 KB |
testcase_07 | AC | 3 ms
4,380 KB |
testcase_08 | AC | 863 ms
15,524 KB |
testcase_09 | AC | 100 ms
8,172 KB |
testcase_10 | AC | 1,382 ms
18,524 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
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 M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<ll> VI; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> t3; typedef tuple<ll, ll, ll, ll> t4; typedef tuple<ll, ll, ll, ll, ll> t5; #define rep(a,n) for(ll a = 0;a < n;a++) #define repi(a,b,n) for(ll a = b;a < n;a++) using namespace std; static const ll INF = 1e15; const ll mod = 1000000007; template<typename T> static inline void chmin(T & ref, const T value) { if (ref > value) ref = value; } template<typename T> static inline void chmax(T& ref, const T value) { if (ref < value) ref = value; } int main() { //dp[i][j]...i-1番目までで、j個に分割している個数 ll n, m, k; cin >> n >> k >> m; vector<ll> as(n); vector<ll> sums(n+1, 0); rep(i, n) { cin >> as[i]; sums[i + 1] = sums[i] + as[i]; } vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, -INF)); dp[0][0] = 0; for (int right = 0; right < n; right++) { for (int j = 1; j <= k; j++) { for (int left = 0; left <= right; left++) { if (left + 1 < j) continue; if (right - left + 1 > m) continue; ll add = abs(sums[right + 1] - sums[left]); ll np = add + dp[left][j - 1]; chmax(dp[right + 1][j], np); } } } ll up = 0; for (int i = 1; i <= k; i++) { chmax(up, dp[n][i]); } cout << up << endl; return 0; }