結果
| 問題 |
No.1199 お菓子配り-2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-09 17:01:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 146 ms / 1,000 ms |
| コード長 | 481 bytes |
| コンパイル時間 | 2,437 ms |
| コンパイル使用メモリ | 197,016 KB |
| 最終ジャッジ日時 | 2025-01-14 08:53:29 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | int n,m; scanf("%d%d",&n,&m);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:15:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | lint tmp; scanf("%lld",&tmp);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
const long long INF=1LL<<61;
int main(){
int n,m; scanf("%d%d",&n,&m);
vector<lint> a(n);
rep(i,n){
rep(j,m){
lint tmp; scanf("%lld",&tmp);
a[i]+=tmp;
}
}
vector dp(n+1,vector(2,-INF));
dp[0][1]=0;
rep(i,n){
dp[i+1][0]=max(dp[i][0],dp[i][1]+a[i]);
dp[i+1][1]=max(dp[i][1],dp[i][0]-a[i]);
}
printf("%lld\n",max(dp[n][0],dp[n][1]));
return 0;
}