結果
| 問題 | No.1199 お菓子配り-2 |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-08-22 07:04:26 |
| 言語 | C++17(clang) (clang++ 22.1.8 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 302 ms / 1,000 ms |
| + 16µs | |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 5,915 ms |
| コンパイル使用メモリ | 141,148 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-19 10:33:56 |
| 合計ジャッジ時間 | 25,368 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
コンパイルメッセージ
main.cpp:29:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
29 | ll dp[N + 1][2];
| ^~~~~
main.cpp:29:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
17 | int N, M;
| ^
1 warning generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, M;
cin >> N >> M;
vector<ll> sum(N, 0);
ll a;
for (int i = 0; i < N; ++i) {
for (int j = 0; j < M; ++j) {
cin >> a;
sum[i] += a;
}
}
ll dp[N + 1][2];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < N; ++i) {
ll s = sum[i];
dp[i + 1][0] = max(dp[i + 1][0], max(dp[i][0], dp[i][1] - s));
dp[i + 1][1] = max(dp[i + 1][1], max(dp[i][1], dp[i][0] + s));
}
cout << max(dp[N][0], dp[N][1]) << endl;
return 0;
}
siman