結果
問題 | No.1199 お菓子配り-2 |
ユーザー |
|
提出日時 | 2020-08-28 22:17:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 124 ms / 1,000 ms |
コード長 | 980 bytes |
コンパイル時間 | 1,846 ms |
コンパイル使用メモリ | 172,608 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-14 03:36:26 |
合計ジャッジ時間 | 8,834 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for (int i = 0; i < (int)(n); i ++)#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)using namespace std;using ll = long long;using PL = pair<ll,ll>;using P = pair<int,int>;constexpr int INF = 1000000000;constexpr long long HINF = 1000000000000000;constexpr long long MOD = 1000000007;// = 998244353;constexpr double EPS = 1e-4;constexpr double PI = 3.14159265358979;int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int N,M; cin >> N >> M;vector<ll> A(N);rep(i,N) {ll x = 0;rep(j,M) {ll a; cin >> a;x += a;}A[i] = x;}vector<vector<ll>> dp(N + 1,vector<ll>(N + 1,0));rep(i,N) {rep(j,N) {dp[i + 1][j + 1] = max(dp[i][j + 1],dp[i][j] + (j%2 ? -1: 1) * A[i]);}}ll ans = 0;rep(i,N + 1) {ans = max(ans,dp[N][i]);}cout << ans << '\n';return 0;}