제출 #1147106

#제출 시각아이디문제언어결과실행 시간메모리
1147106sushanth123Knapsack (NOI18_knapsack)C++20
0 / 100
0 ms324 KiB
#include<bits/stdc++.h> using namespace std; int main(){ long long s,n; cin >> s,n; vector<tuple<long long ,long long, long long>> in(n); long long total; total = 0; for(int i=0;i<n;i++){ long long x,y,z; cin >> x >> y >> z; in[i] = {x,y,z}; total += z; } long long dp[s+1][total+1] = {}; for(int i=1;i<=s;i++){ for(int j=1;j<=total;j++){ if(get<1>(in[j-1]) <= i){ dp[i][j] = max(dp[i][j-1],dp[i-get<1>(in[j-1])][j-1] + get<0>(in[j-1])); } else{ dp[i][j] = dp[i][j-1]; } } } cout << dp[total][s] << endl; }
#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...