QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478238 | #4398. Luxury cruise ship | horzward# | Compile Error | / | / | C++17 | 1.3kb | 2024-07-14 19:26:42 | 2024-07-14 19:26:42 |
Judging History
answer
/*
|----| |----|
| | | |
| ----| |
| |
| ----| |
| | | |
|----| |----|
*/
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int inf = 1e18;
const int N = 1e6;
vector<int> dp(N, inf);
int x[] = {7, 31, 365};
void solve()
{
int n;
cin >> n;
dp[0] = 0;
for(int i = 0; i < 3; i++) {
for(int j = 0; j < N; j++) {
if(j - x[i] >= 0) dp[j] = min(dp[j], dp[j - x[i]] + 1);
}
}
while(n--) {
int now = 0;
cin >> now;
// 處理now < N的狀況
if(now < N) {
cout << (dp[now] == inf ? -1 : dp[now]) << '\n';
}
else {
int tmp = now - N;
tmp = (tmp % 365 == 0 ? tmp / 365 : tmp / 365 + 1);
int after = now - tmp * 365;
cout << (dp[after] == inf ? -1 : tmp + dp[after]) << '\n';
}
}
return;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while(t--)
{
solve();
}
return 0;
}
Details
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 answer.code:14: /usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<long long int, std::allocator<long 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 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 | ^~~~~~~~~~~~