結果
問題 | No.952 危険な火薬庫 |
ユーザー | nanophoto12 |
提出日時 | 2021-12-12 10:46:35 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,356 bytes |
コンパイル時間 | 4,442 ms |
コンパイル使用メモリ | 263,196 KB |
実行使用メモリ | 54,080 KB |
最終ジャッジ日時 | 2023-09-28 02:34:20 |
合計ジャッジ時間 | 8,865 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
8,712 KB |
testcase_01 | AC | 2 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,356 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> #define M_PI 3.14159265358979323846 // pi using namespace std; typedef long long ll; typedef unsigned long long ull; 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++) 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; } #include <atcoder/all> using namespace atcoder; typedef modint998244353 mint; mint mpow(mint x, ll n) { mint ans = 1; while (n != 0) { if (n & 1) ans = ans * x; x = x * x; n = n >> 1; } return ans; } int main() { ll n; cin >> n; vector<ll> as(n); rep(i, n) cin >> as[i]; vector<ll> ss(n + 1, 0); rep(i, n) ss[i + 1] = ss[i] + as[i]; //dp[i][j]...dp[i-1][j-1] vector<vector<ll>> dp(n + 2, vector<ll>(n + 1, 1e15)); dp[0][0] = 0; for (int i = 0; i < n + 1; i++) { for (int j = 0; j < n + 1; j++) { ll lower = 1e15; for (int k = 0; k <= i; k++) { if (i - k < 0) continue; if (j - k < 0) continue; ll s = ss[i] - ss[i - k]; chmin(lower, dp[i - k][j - k] + s * s); } dp[i + 1][j] = lower; } } for (int k = 1; k <= n; k++) { cout << dp[n + 1][k] << endl; } return 0; }