結果
| 問題 | 
                            No.1199 お菓子配り-2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-06 21:44:50 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 469 ms / 1,000 ms | 
| コード長 | 640 bytes | 
| コンパイル時間 | 1,039 ms | 
| コンパイル使用メモリ | 105,524 KB | 
| 最終ジャッジ日時 | 2025-01-14 08:03:54 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 45 | 
ソースコード
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
int main() {
	int n, m; std::cin >> n >> m;
	long long int odd{ 0 }, even{ LLONG_MIN >> 1};
	for (auto i = 0; i < n; ++i) {
		long long int h{ 0 };
		for (auto i = 0; i < m; ++i) {
			long long int a; std::cin >> a;
			h += a;
		}
		const auto o = std::max(odd, even - h);
		const auto e = std::max(even, odd + h);
		odd = o;
		even = e;
	}
	std::cout << std::max(odd, even) << '\n';
}