QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528233 | #7279. Tricks of the Trade | skittles1412# | Compile Error | / | / | C++17 | 2.7kb | 2024-08-23 11:51:31 | 2024-08-23 11:51:33 |
Judging History
This is the latest submission verdict.
- [2024-08-23 11:51:33]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-08-23 11:51:31]
- Submitted
answer
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
// cf bits/extc++.h nonsense
#ifdef ONLINE_JUDGE
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#endif
#include "bits/extc++.h"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
using ll = long long;
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
inline void init_io() {
cin.tie(nullptr);
cin.exceptions(ios::failbit);
ios_base::sync_with_stdio(false);
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
out << "[";
for (int i = 0; i < sz(arr); i++) {
if (i) {
out << ", ";
}
out << arr[i];
}
return out << "]";
}
template <typename T>
struct PSA {
int n;
vector<T> psum;
template <typename U>
PSA(const vector<U>& arr) : n(sz(arr)), psum(n + 1) {
for (int i = 0; i < n; i++) {
psum[i + 1] = psum[i] + arr[i];
}
}
T query(int l, int r) const {
return psum[r] - psum[l];
}
};
template <typename T>
bool on(T mask, int bit) {
return (mask >> bit) & 1;
}
void solve() {
int n, kv;
cin >> n >> kv;
vector<long> costs(n), vals(n);
for (auto& a : costs) {
cin >> a;
}
for (auto& a : vals) {
cin >> a;
}
PSA<long> costs_psa(costs);
long buf1[kv + 1] alignas(1024), buf2[kv + 1] alignas(1024);
long *cdp alignas(1024) = buf1, *pdp alignas(1024) = buf2;
fill_n(cdp, kv + 1, -1e18);
fill_n(pdp, kv + 1, -1e18);
// vector<long> cdp(kv + 1, long(-1e18)), pdp(kv + 1, long(-1e18));
cdp[kv] = -costs_psa.psum[n];
// vector dp(n + 1, vector(kv + 1, long(-1e18)));
// for (int i = 0; i <= n; i++) {
// dp[i][kv] = -costs_psa.psum[i];
// }
long ans = -1e18;
for (int i = n - 1; i >= 0; i--) {
swap(cdp, pdp);
const int mx_iter = min(kv, (i + 16) & (~15));
// const int mx_iter = kv;
#pragma GCC ivdep
for (int j = max(0, (kv - (n - i) - 10) & (~15)); j < mx_iter; j++) {
cdp[j] = max(pdp[j], pdp[j + 1] + vals[i]);
}
ans = max(ans, cdp[0] + costs_psa.psum[i]);
cdp[kv] = -costs_psa.psum[i];
}
// for (int i = 0; i <= n; i++) {
// ans = max(ans, dp[i][0] + costs_psa.psum[i]);
// }
cout << ans << endl;
}
int main() {
init_io();
solve();
}
详细
In file included from /usr/include/c++/13/string:43, from /usr/include/c++/13/bitset:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52, from /usr/include/x86_64-linux-gnu/c++/13/bits/extc++.h:32, from answer.code:9: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<long int, std::allocator<long int> >::_Vector_impl::~_Vector_impl()’: /usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long int]’: target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/13/vector:66, from /usr/include/c++/13/functional:64, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53: /usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here 133 | struct _Vector_impl | ^~~~~~~~~~~~