이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
//const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second
ll knapsack(vector<pair<int,int>>arr,int s){ // (weight, reward)
vector<vector<ll>>dp(arr.size()+1,vector<ll>(s+1)); // dp[i][j] = if we take first i elements, how much can we take with j space left
/*for(int i=1;i<=arr.size();i++){
for(int j=0;j<=s;j++){
dp[i][j]=dp[i-1][j];
if(j-arr[i-1].first>=0){
dp[i][j]=max(dp[i][j],dp[i-1][j-arr[i-1].first]+arr[i-1].second);
}
}
}*/
//return dp[(int)arr.size()][s];
return 0;
}
void solve(){
int s,n;
cin>>s>>n;
vector<pair<int,int>>arr;
for(int i=0;i<n;i++){
int w,r,c;
cin>>r>>w>>c;
while(c--){
arr.emplace_back(w,r);
}
}
cout<<knapsack(arr,s)<<"\n";
}
int main(){
ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
//freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
int t=1;//cin>>t;
while(t--)solve();
return 0;
}
/*
15 5
4 12 1
2 1 1
10 4 1
1 1 1
2 2 1
20 3
5000 15 1
100 1 3
50 1 4
*/
# | 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... |