이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ll s,n;
cin>>s>>n;
vector<ll>ws;
vector<ll>vs;
for(ll i=0;i<n;i++){
ll v,w,k;
cin>>v>>w>>k;
ws.push_back(w);
vs.push_back(v);
}
vector<vector<ll>>dp(s+1,vector<ll>(n+1,0));
for(ll j=1;j<=s;j++){
for(int i=1;i<=n;i++){
if(j>=ws[i]){
dp[j][i]=max(dp[j][i],dp[j-ws[i]][i-1]+vs[i]);
}
dp[j][i]=max(dp[j][i],dp[j][i-1]);
}
}
cout<<dp[s][n];
return 0;
}
# | 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... |