結果
問題 | No.1199 お菓子配り-2 |
ユーザー |
![]() |
提出日時 | 2020-08-28 21:51:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 115 ms / 1,000 ms |
コード長 | 1,229 bytes |
コンパイル時間 | 1,772 ms |
コンパイル使用メモリ | 170,916 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 03:22:12 |
合計ジャッジ時間 | 8,695 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;typedef long double ld;using P = pair<ll,ll>;constexpr ll mod = 1e9+7;#define ALL(x) (x).begin(),(x).end()#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)#define pb push_back#define eb emplace_back#define mp make_pair#define F first#define S second#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());template<class T> inline void chmin(T& a, T b){if (a > b){a = b;}}template<class T> inline void chmax(T& a, T b){if (a < b){a = b;}}signed main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);ll N,M;cin >> N >> M;vector<ll> A(N);REP(i,N){REP(l,M){ll tmp;cin >> tmp;A[i] += tmp;}}vector<ll> dpse(N+1,-10000000000000000);vector<ll> dphu(N+1,-10000000000000000);dpse[0] = 0;REP(i,N){dpse[i+1] = max(dphu[i] - A[i],dpse[i]);dphu[i+1] = max(dpse[i] + A[i],dphu[i]);}cout << max(dpse[N],dphu[N]) << "\n";}