Submission #961909

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9619092024-04-12 18:14:29Bee_RKnapsack (NOI18_knapsack)C++17
73 / 100
101 ms262144 KiB
#include <bits/stdc++.h>
#define int long long
#define f cin
#define g cout
using namespace std;
/*ifstream f("knap.in");
ofstream g("knap.out");*/
vector<vector<int>> used;
vector<int> dp, weight, value;
int s, n, result;
int32_t main(){
f>>s>>n;
used.resize(s+1,vector<int>(n+1,0));
weight.resize(n+1);
value.resize(n+1);
for(int i=1;i<=n;i++){
f>>value[i]>>weight[i]>>used[0][i];
}
dp.resize(s+1,0);
for(int i=1;i<=s;i++){
int mx=0, mxv=0;
for(int j=1;j<=n;j++){
int k=i-weight[j];
if(k>=0 && dp[k]+value[j]>mxv && used[k][j]>0){
mx=j;
mxv=dp[k]+value[j];
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...