Submission #899773

#TimeUsernameProblemLanguageResultExecution timeMemory
899773GhettoKnapsack (NOI18_knapsack)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; using pli = pair<lint, int>; const int MAX_N = 1e5 + 5, MAX_S = 2000 + 5; int s, n; lint v[MAX_N]; int w[MAX_N], k[MAX_N]; lint dp[2][MAX_S]; deque<pli> trans[MAX_N][MAX_S]; int main() { // freopen("knapsack.in", "r", stdin); cin >> s >> n; for (int i = 1; i <= n; i++) { cin >> v[i] >> w[i] >> k[i]; k[i] = min(k[i], s); } for (int i = n; i >= 1; i--) { int parity = i % 2, opp_parity = (i + 1) % 2; for (int c = 0; c <= s; c++) { if (c < w[i]) { trans[i][c].push_back({dp[opp_parity][c], c}); dp[parity][c] = dp[opp_parity][c]; } else { lint val = dp[opp_parity][c] - v[i] * (c / w[i]); while (trans[i][c % w[i]].size() && trans[i][c % w[i]].back().first <= val) trans[i][c % w[i]].pop_back(); trans[i][c % w[i]].push_back({val, c}); while (trans[i][c % w[i]].front().second < c - k[i] * w[i]) trans[i][c % w[i]].pop_front(); int new_c = trans[i][c % w[i]].front().second; dp[parity][c] = dp[opp_parity][new_c] + v[i] * ((c - new_c) / w[i]); } // cout << i << " " << c << ": " << dp[parity][c] << endl; } } cout << dp[1][s] << '\n'; }

Compilation message (stderr)

/tmp/ccRgZcx8.o: in function `main':
knapsack.cpp:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
knapsack.cpp:(.text.startup+0x19): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0x28): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `std::cin' defined in .bss._ZSt3cin section in /usr/lib/gcc/x86_64-linux-gnu/10/libstdc++.a(globals_io.o)
knapsack.cpp:(.text.startup+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0xa6): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0xc3): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccRgZcx8.o
knapsack.cpp:(.text.startup+0xe0): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status