結果
問題 | No.1199 お菓子配り-2 |
ユーザー |
![]() |
提出日時 | 2021-02-08 16:54:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 423 ms / 1,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 734 ms |
コンパイル使用メモリ | 74,112 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 18:57:35 |
合計ジャッジ時間 | 16,235 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;using ll = long long;const int INF = 100100100;int main(){int n , m;cin >> n >> m;vector<ll> a(n + 1 , 0);for(int i = 1; i <= n; i++){for(int j = 0; j < m; j++){ll now;cin >> now;a[i] += now;}}vector<vector<ll>> dp(n + 10 , vector<ll>(2 , 0));for(int i = 1; i <= n; i++){dp[i][1] = max({dp[i - 1][1] , dp[i - 1][0] + a[i] , a[i]});dp[i][0] = max(dp[i - 1][0] , dp[i - 1][1] - a[i]);}cout << max(dp[n][1] , dp[n][0]) << endl;return 0;}