Submission #1288305

#TimeUsernameProblemLanguageResultExecution timeMemory
1288305pecorineKnapsack (NOI18_knapsack)C++20
0 / 100
148 ms327680 KiB
#include <bits/stdc++.h> // clang-format off #define princess_connect(file,extention) if(fopen(file "." extention, "r")) freopen(file "." extention, "r", stdin) #define yabai_desune ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define __Pecorine__ signed main() #define For(i, l, r) for (int i = l; i <= r; i++) #define Fod(i, r, l) for (int i = r; i >= l; i--) #define ll long long #define pb push_back #define sz(yuuki) (int)yuuki.size() #define bit(x,i) (x >> i) & 1 #define endl "\n" using namespace std;/* // ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠙⠻⠟⠛⠻⢿⣿⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⣿ ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿ ⣿⣿⣿⡟⠿⠿⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣀⠀⢸⣿ ⣿⡄⠀⠀⠀⠀⠀⠻⠿⣿⣿⣿⣿⣿⡷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣼⣿⣿⣿ ⣿⣷⡀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠛⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿ ⣿⣿⣿⣷⣶⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿ ⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠋⣉⣽ ⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿ ⣿⣿⣿⣿⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿ */ // clang-format on const int inf = 2e9; const int mxn = 1e5 + 7; const int mod = 1e9 + 7; int s, n; vector<int> v(mxn), w(mxn), k(mxn); vector<vector<int>> f(mxn, vector<int>(2007)); __Pecorine__ { yabai_desune; princess_connect("yabai", "desune"); cin >> s >> n; For(i, 1, n) { cin >> v[i] >> w[i] >> k[i]; } For(i, 1, n) { For(j, 1, s) { f[i][j] = f[i - 1][j]; For(l, 1, k[i]) { if (j >= l * w[i]) { f[i][j] = max(f[i][j], f[i - 1][j - l * w[i]] + l * v[i]); } else break; } } } cout << f[n][s] << endl; // For(i, 1, n) { // For(j, 1, s) cout << f[i][j] << " "; // cout << endl; // } }

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:2:84: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    2 | #define princess_connect(file,extention) if(fopen(file "." extention, "r")) freopen(file "." extention, "r", stdin)
      |                                                                             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
knapsack.cpp:41:5: note: in expansion of macro 'princess_connect'
   41 |     princess_connect("yabai", "desune");
      |     ^~~~~~~~~~~~~~~~
#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...