結果
| 問題 |
No.1199 お菓子配り-2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-28 21:34:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 115 ms / 1,000 ms |
| コード長 | 596 bytes |
| コンパイル時間 | 1,734 ms |
| コンパイル使用メモリ | 165,980 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-14 02:57:41 |
| 合計ジャッジ時間 | 8,368 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char newl = '\n';
constexpr ll INF = 1e18;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
ll dpo = -INF, dpe = 0;
for (int i = 0; i < n; i++) {
ll sum = 0;
for (int j = 0; j < m; j++) {
ll a;
cin >> a;
sum += a;
}
ll ndpo = max(dpo, dpe + sum);
ll ndpe = max(dpe, dpo - sum);
dpo = ndpo;
dpe = ndpe;
}
cout << max(dpo, dpe) << newl;
return 0;
}