結果
問題 | No.3014 岩井満足性問題 |
ユーザー |
![]() |
提出日時 | 2025-01-28 15:33:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 3,000 ms |
コード長 | 1,000 bytes |
コンパイル時間 | 386 ms |
コンパイル使用メモリ | 41,728 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-28 15:33:58 |
合計ジャッジ時間 | 1,430 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d%d%d", &n, &d, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:35:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | for (int i = 0; i < n; i++) scanf("%d", as + i); | ~~~~~^~~~~~~~~~~~~~ main.cpp:36:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | for (int i = 0; i < n; i++) scanf("%d", cs + i); | ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 3014.cc: No.3014 蟯ゥ莠墓コ雜ウ諤ァ蝠城。・- yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 500; const int MAX_K = 500; const long long LINF = 1LL << 62; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N], cs[MAX_N]; ll dp[MAX_N + 1][MAX_K + 1]; /* subroutines */ inline void setmax(ll &a, ll b) { if (a < b) a = b; } /* main */ int main() { int n, d, k; scanf("%d%d%d", &n, &d, &k); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = 0; i < n; i++) scanf("%d", cs + i); for (int j = 0; j <= d; j++) fill(dp[j], dp[j] + k + 1, -LINF); dp[0][0] = 0; for (int i = 0; i < n; i++) { for (int j = min(i, d - 1); j >= 0; j--) for (int l = k; l >= 0; l--) if (dp[j][l] > -LINF) setmax(dp[j + 1][min(l + cs[i], k)], dp[j][l] + as[i]); } if (dp[d][k] > -LINF) printf("%lld\n", dp[d][k]); else puts("No"); return 0; }