QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#663359 | #5549. Game Show | ucup-team3519# | Compile Error | / | / | C++17 | 1.6kb | 2024-10-21 15:03:32 | 2024-10-21 15:03:33 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = int64_t;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, q;
std::cin >> n >> q;
std::vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
for (int i = 0; i < n; ++i) {
std::cin >> b[i];
}
a.insert(a.end(), a.begin(), a.end());
b.insert(b.end(), b.begin(), b.end());
bool flawed = false;
for (int i = 0; i < n; ++i) {
if (a[i] + b[i] < 0) {
flawed = true;
break;
}
}
if (std::accumulate(a.begin(), a.end(), 0LL) < 0 ||
std::accumulate(b.begin(), b.end(), 0LL) < 0) {
flawed = true;
}
if (flawed) {
for (int i = 0; i < q; ++i) {
std::cout << "flawed\n";
}
return 0;
}
std::vector<i64> sa(n * 2), sb(n * 2);
sa[0] = a[0];
sb[0] = b[0];
for (int i = 1; i < sa.size(); ++i) {
sa[i] = sa[i - 1] + a[i];
sb[i] = sb[i - 1] + b[i];
}
// std::partial_sum(a.begin(), a.end(), sa.begin());
// std::partial_sum(b.begin(), b.end(), sb.begin());
while (q--) {
int s, t;
std::cin >> s >> t;
--s, --t;
if (s == t) {
std::cout << "0\n";
} else {
if (s > t) {
t += n;
}
i64 ans = sa[t - 1] - (s ? sa[s - 1] : 0LL);
if (s < t) {
s += n;
}
ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL));
std::cout << ans << '\n';
}
}
}
详细
answer.code: In function ‘int main()’: answer.code:65:27: error: no matching function for call to ‘min(i64&, long long int)’ 65 | ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51, from answer.code:1: /usr/include/c++/13/bits/stl_algobase.h:233:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)’ 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: answer.code:65:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’) 65 | ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)’ 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algobase.h:281:5: note: template argument deduction/substitution failed: answer.code:65:27: note: deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’) 65 | ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/algorithm:61: /usr/include/c++/13/bits/stl_algo.h:5775:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)’ 5775 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5775:5: note: template argument deduction/substitution failed: answer.code:65:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’ 65 | ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)’ 5785 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/13/bits/stl_algo.h:5785:5: note: template argument deduction/substitution failed: answer.code:65:27: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘long int’ 65 | ans = std::min(ans, sb[s - 1] - (t ? sb[t - 1] : 0LL)); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~