| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1147496 | aaa@222 | Knapsack (NOI18_knapsack) | C++20 | 0 ms | 324 KiB |
#include<bits/stdc++.h>
using namespace std;
#define el cout<<"\n";
#define ll long long
#define maxn 100005
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, s; cin >> n >> s;
vector<int> w(n + 1), v(n + 1);
vector<vector<int>> dp(n + 1, vector<int>(s + 1));
for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
for(int i = 1; i <= n; i++){
for(int j = 0; j <= s; j++) dp[i][j] = max(dp[i - 1][j], (w[i] <= j) ? (dp[i - 1][j - w[i]] + v[i]) : -1);
}
cout << dp[n][s];
}| # | 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... | ||||
