Submission #1023728

#TimeUsernameProblemLanguageResultExecution timeMemory
1023728vjudge1Knapsack (NOI18_knapsack)C++17
73 / 100
295 ms262144 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() { ios::sync_with_stdio(false); cin.tie(); cout.tie(); 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 <= min(c, s); 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:26: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]
   26 |     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...