結果
| 問題 |
No.1199 お菓子配り-2
|
| コンテスト | |
| ユーザー |
iqueue02
|
| 提出日時 | 2020-08-28 23:10:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 652 bytes |
| コンパイル時間 | 2,436 ms |
| コンパイル使用メモリ | 194,428 KB |
| 最終ジャッジ日時 | 2025-01-13 19:18:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 45 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr ll INF = (1LL << 60);
int main(){
int n, m;
cin >> n >> m;
vector<ll> a(n, 0);
rep(i,n) {
rep(j,m) {
ll b;
cin >> b;
a[i] += b;
}
}
vector<ll> dp(2, 0);
ll res = 0;
for (int i = 0; i < n; i++) {
vector<ll> ndp(2, 0);
ndp[0] = max(ndp[0], dp[1] + a[i]);
ndp[1] = max(ndp[1], dp[0] - a[i]);
res = max(res, max(ndp[0], ndp[1]));
dp = move(ndp);
}
cout << res << endl;
return 0;
}
iqueue02