結果

問題 No.3103 Range Chmax and Maximize Abs Sum
ユーザー SSRSSSRS
提出日時 2023-03-31 21:40:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 1,734 ms
コンパイル使用メモリ 169,660 KB
実行使用メモリ 11,048 KB
最終ジャッジ日時 2023-10-24 07:32:18
合計ジャッジ時間 6,432 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<long long> dp(N + 1, 0);
  for (int i = 0; i < N; i++){
    long long mx = -INF;
    for (int j = i; j < N; j++){
      mx = max(mx, A[j]);
      dp[j + 1] = max(dp[j + 1], dp[i] + (long long) abs(mx) * (j - i + 1));
    }
  }
  cout << dp[N] << endl;
}
0