| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1188102 | abcd1234 | Knapsack (NOI18_knapsack) | C++20 | 1095 ms | 5892 KiB |
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int s, n; cin >> s >> n;
vector<vector<long long>> store(n, vector<long long>(3));
vector<bool> processed(s + 1, false);
long long ans = 0;
processed[0] = true;
for(int i = 0; i < n; i++)
{
cin >> store[i][0] >> store[i][1];
long long temp; cin >> temp;
store[i][2] = min(s / store[i][1], temp);
}
vector<long long> dp(s + 1, 0);
for(int i = 0; i < n; i++)
{
while(store[i][2] > 0 )
{
for(int j = s; j >= store[i][1]; j--)
{
if(processed[j - store[i][1]])
{
dp[j] = max(dp[j - store[i][1]] + store[i][0], dp[j]);
ans = max(dp[j], ans);
processed[j] = true;
}
}
store[i][2]--;
}
}
cout << ans << endl;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
