結果
| 問題 |
No.1199 お菓子配り-2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-06 21:49:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 417 ms / 1,000 ms |
| コード長 | 819 bytes |
| コンパイル時間 | 2,889 ms |
| コンパイル使用メモリ | 250,828 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-26 15:59:24 |
| 合計ジャッジ時間 | 17,823 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
typedef long long ll;
typedef unsigned long long ull;
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
//const ll MOD = 998244353;
//const ll MOD = 1000000007;
int main()
{
ll N,M; cin >> N >> M;
vector<ll> V(N);
for(int i = 0; i < N; i++)
{
for(int j = 0; j < M; j++)
{
ll A; cin >> A;
V[i] += A;
}
}
vector<vector<ll>> DP(N+1,vector<ll>(2,MINLL));
DP[0][0] = 0;
for(int i = 0; i < N; i++)
{
DP[i+1][0] = max({DP[i+1][0],DP[i][0],DP[i][1]-V[i]});
DP[i+1][1] = max({DP[i+1][1],DP[i][1],DP[i][0]+(V[i])});
}
cout << max(DP[N][0],DP[N][1]) << endl;
return 0;
}