Submission #401320

#TimeUsernameProblemLanguageResultExecution timeMemory
401320hgmhc앱 (KOI13_app)C++14
21 / 21
5 ms4172 KiB
#include <iostream> using namespace std; const int maxn = 100, maxp = 1e4; int n, M, m[maxn+1], c[maxn+1], dp[maxn+1][maxp+1]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> M; for (int i = 1; i <= n; ++i) cin >> m[i]; for (int i = 1; i <= n; ++i) cin >> c[i]; for (int k = 1; k <= n; ++k) { for (int p = 0; p <= maxp; ++p) { dp[k][p] = dp[k-1][p]; if (p-c[k] >= 0) dp[k][p] = max(dp[k][p], dp[k-1][p-c[k]]+m[k]); } } for (int p = 0; p <= maxp; ++p) { if (dp[n][p] >= M) { cout << p; return 0; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...