結果
問題 | No.1199 お菓子配り-2 |
ユーザー |
![]() |
提出日時 | 2020-08-28 21:31:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 422 ms / 1,000 ms |
コード長 | 1,073 bytes |
コンパイル時間 | 1,688 ms |
コンパイル使用メモリ | 171,240 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 02:54:03 |
合計ジャッジ時間 | 16,724 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h> //#include <chrono> //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector<ll> vec; typedef vector<vec> mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair<ll, ll> P; const ll INF = (1LL<<58); template<class T> bool chmin(T &a, const T &b){ if(a > b) {a = b; return true;} else return false; } template<class T> bool chmax(T &a, const T &b){ if(a < b) {a = b; return true;} else return false; } int main() { cin>>N>>M; vec score(N); rep(i,N){ vec temp(M); rep(j, M) cin>>temp[j]; score[i] = accumulate(ALL(temp), 0LL); } vec dp(2, 0); dp[1] = -INF; rep(i,N){ ll temp = max(dp[1], dp[0] + score[i]); chmax(dp[0], dp[1] - score[i]); chmax(dp[1], temp); } cout<<max(dp[0], dp[1])<<endl; }