結果

問題 No.1199 お菓子配り-2
ユーザー 👑 kmjpkmjp
提出日時 2020-08-28 22:38:18
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 988 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 199,864 KB
実行使用メモリ 11,556 KB
最終ジャッジ日時 2023-08-08 22:52:18
合計ジャッジ時間 9,516 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 31 ms
9,508 KB
testcase_04 AC 73 ms
10,652 KB
testcase_05 AC 4 ms
4,384 KB
testcase_06 AC 5 ms
4,384 KB
testcase_07 AC 37 ms
7,436 KB
testcase_08 AC 50 ms
7,740 KB
testcase_09 AC 32 ms
7,572 KB
testcase_10 AC 9 ms
4,540 KB
testcase_11 AC 24 ms
7,536 KB
testcase_12 AC 23 ms
5,136 KB
testcase_13 AC 9 ms
4,380 KB
testcase_14 AC 8 ms
4,824 KB
testcase_15 AC 6 ms
4,384 KB
testcase_16 AC 47 ms
7,472 KB
testcase_17 AC 24 ms
7,276 KB
testcase_18 AC 51 ms
10,468 KB
testcase_19 AC 14 ms
7,128 KB
testcase_20 AC 86 ms
10,388 KB
testcase_21 AC 55 ms
11,032 KB
testcase_22 AC 32 ms
9,716 KB
testcase_23 AC 40 ms
10,128 KB
testcase_24 AC 55 ms
10,520 KB
testcase_25 AC 10 ms
4,760 KB
testcase_26 AC 62 ms
9,488 KB
testcase_27 AC 52 ms
7,436 KB
testcase_28 AC 118 ms
11,280 KB
testcase_29 AC 115 ms
11,288 KB
testcase_30 AC 116 ms
11,264 KB
testcase_31 AC 117 ms
11,264 KB
testcase_32 AC 114 ms
11,336 KB
testcase_33 AC 113 ms
11,244 KB
testcase_34 AC 112 ms
11,428 KB
testcase_35 AC 119 ms
11,404 KB
testcase_36 AC 115 ms
11,556 KB
testcase_37 AC 116 ms
11,296 KB
testcase_38 AC 116 ms
11,296 KB
testcase_39 AC 117 ms
11,488 KB
testcase_40 AC 112 ms
11,556 KB
testcase_41 AC 112 ms
11,484 KB
testcase_42 AC 116 ms
11,352 KB
testcase_43 AC 117 ms
11,356 KB
testcase_44 AC 112 ms
11,404 KB
testcase_45 AC 110 ms
11,264 KB
testcase_46 AC 113 ms
11,344 KB
testcase_47 AC 117 ms
11,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
ll A[1010][1010];

ll dp[1010][2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	dp[0][0]=0;
	dp[0][1]=-1LL<<60;
	
	cin>>H>>W;
	FOR(y,H) {
		ll V=0;
		FOR(x,W) {
			cin>>A[y][x];
			V+=A[y][x];
		}
		dp[y+1][0]=max(dp[y][0],dp[y][1]-V);
		dp[y+1][1]=max(dp[y][1],dp[y][0]+V);
	}
	cout<<dp[H][1]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0