結果
| 問題 |
No.1199 お菓子配り-2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-09 16:57:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 477 bytes |
| コンパイル時間 | 2,389 ms |
| コンパイル使用メモリ | 197,548 KB |
| 最終ジャッジ日時 | 2025-01-14 08:52:54 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | WA * 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:39: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | int tmp; scanf("%d",&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<int> a(n);
rep(i,n){
rep(j,m){
int tmp; scanf("%d",&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[0][1]+a[i]);
dp[i+1][1]=max(dp[i][1],dp[0][0]-a[i]);
}
printf("%lld\n",max(dp[n][0],dp[n][1]));
return 0;
}