結果

問題 No.1199 お菓子配り-2
ユーザー 57tggx57tggx
提出日時 2020-07-20 18:52:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 419 ms / 1,000 ms
コード長 419 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 66,920 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 02:21:38
合計ジャッジ時間 15,506 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using ll = long long;

ll chmax(ll &x, const ll &y){
	if(x < y) x = y;
	return x;
}

int main(){
	int n, m;
	std::cin >> n >> m;
	ll plus = 0, minus = 0;
	for(int i = 0; i < n; ++i){
		ll a = 0;
		for(int j = 0; j < m; ++j){
			ll tmp;
			std::cin >> tmp;
			a += tmp;
		}
		chmax(plus, minus + a);
		chmax(minus, plus - a);
	}
	std::cout << std::max(plus, minus) << std::endl;
}
0