Submission #1023724

#TimeUsernameProblemLanguageResultExecution timeMemory
1023724vjudge1Knapsack (NOI18_knapsack)C++17
37 / 100
1016 ms49808 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define ff first #define ss second #pragma GCC optimize("O3") #pragma GCC target("avx2") const int inf = 1e9; signed main() { int n, s; cin >> s >> n; vector<int> v, w; for (int i = 0; i < n; i++) { int a, b, c; cin >> a >> b >> c; for (int j = 1; j <= c; j++) { v.pb(a); w.pb(b); } } vector<int> dp(s + 1, 0); for (int i = 0; i < v.size(); i++) { for (int j = s; j >= w[i]; j--) { dp[j] = max(dp[j], dp[j - w[i]] + v[i]); } } cout << dp[s]; }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:23:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...