結果
| 問題 | No.2317 Expression Menu |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-05-29 00:36:12 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 2,000 ms |
| コード長 | 881 bytes |
| 記録 | |
| コンパイル時間 | 2,982 ms |
| コンパイル使用メモリ | 147,072 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-02 08:18:19 |
| 合計ジャッジ時間 | 4,131 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
main.cpp:20:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
20 | int A[N];
| ^
main.cpp:20: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, X, Y;
| ^
main.cpp:21:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
21 | int B[N];
| ^
main.cpp:21: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, X, Y;
| ^
main.cpp:22:8: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
22 | ll C[N];
| ^
main.cpp:22:8: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:17:7: note: declared here
17 | int N, X, Y;
| ^
main.cpp:27:16: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
27 | ll dp[X + 1][Y + 1];
| ^~~~~
main.cpp:27:16: note: read of non-const variable 'Y' is not allowed in a constant expression
main.cpp:17:13: note: declared here
17 | int N, X, Y;
| ^
main.cpp:27:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
27 | ll dp[X + 1][Y + 1];
| ^~~~~
main.cpp:27:9: note: read of non-const variable 'X' is not allowed in a constant expression
main.cpp:17:10: note: declared here
17 | int N, X, Y;
| ^
5 warnings generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, X, Y;
cin >> N >> X >> Y;
int A[N];
int B[N];
ll C[N];
for (int i = 0; i < N; ++i) {
cin >> A[i] >> B[i] >> C[i];
}
ll dp[X + 1][Y + 1];
memset(dp, -1, sizeof(dp));
dp[0][0] = 0;
ll ans = 0;
for (int i = 0; i < N; ++i) {
int a = A[i];
int b = B[i];
ll c = C[i];
for (int x = X - a; x >= 0; --x) {
int nx = x + a;
for (int y = Y - b; y >= 0; --y) {
int ny = y + b;
if (dp[x][y] == -1) continue;
dp[nx][ny] = max(dp[nx][ny], dp[x][y] + c);
ans = max(ans, dp[nx][ny]);
}
}
}
cout << ans << endl;
return 0;
}
siman