Submission #1100450

#TimeUsernameProblemLanguageResultExecution timeMemory
1100450baoheyheyKnapsack (NOI18_knapsack)C++17
17 / 100
1 ms504 KiB
#include <bits/stdc++.h>
#define MAXN 100004
#define MAXS 2004
using namespace std;
int s,n,w[MAXN];
long long v[MAXN],k[MAXN],dp[MAXS];
int main(){
	scanf("%d %d",&s,&n);
	for(int x=0;x<n;x++){
		scanf("%lld %d %lld",&v[x],&w[x],&k[x]);
		for(int y=s;y>=w[x];y--){
			dp[y]=max(dp[y],dp[y-w[x]]+v[x]);
		}
	}
	long long ans=0;
	for(int x=1;x<=s;x++) ans=max(ans,dp[x]);
	printf("%lld\n",ans);
	return 0;
} 

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  scanf("%d %d",&s,&n);
      |  ~~~~~^~~~~~~~~~~~~~~
knapsack.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%lld %d %lld",&v[x],&w[x],&k[x]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...