QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#465825 | #3872. Gym Badges | jdkjrejvm | Compile Error | / | / | C++20 | 1.2kb | 2024-07-07 10:45:28 | 2024-07-07 10:45:28 |
Judging History
This is the latest submission verdict.
- [2024-07-07 10:45:28]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-07-07 10:45:28]
- Submitted
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 500010;
int X[N], L[N];
class FastScanner {
public:
FastScanner() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
int nextInt() {
int x;
cin >> x;
return x;
}
};
int main() {
FastScanner f;
int n = f.nextInt();
priority_queue<int> q;
vector<array<int, 3>> tr;
for (int i = 1; i <= n; ++i) X[i] = f.nextInt();
for (int i = 1; i <= n; ++i) L[i] = f.nextInt();
for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]});
sort(tr.begin(), tr.end());
long long sum = 0, ans = 0;
for (int i = 1; i <= n; ++i) {
auto &c = tr[i - 1];
int X1 = c[1], L1 = c[2];
if (sum <= L1) {
sum += X1;
q.push(X1);
++ans;
} else {
if (!q.empty() && q.top() > X1) {
sum -= q.top();
q.pop();
sum += X1;
q.push(X1);
}
}
}
cout << ans << "\n";
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:32:46: error: no matching function for call to ‘std::vector<std::array<int, 3> >::push_back(<brace-enclosed initializer list>)’ 32 | for (int i = 1; i <= n; ++i) tr.push_back({X[i] + L[i], X[i], L[i]}); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/vector:66, from answer.code:2: /usr/include/c++/13/bits/stl_vector.h:1278:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; value_type = std::array<int, 3>]’ 1278 | push_back(const value_type& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1278:35: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::vector<std::array<int, 3> >::value_type&’ {aka ‘const std::array<int, 3>&’} 1278 | push_back(const value_type& __x) | ~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:1295:7: note: candidate: ‘constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; value_type = std::array<int, 3>]’ 1295 | push_back(value_type&& __x) | ^~~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1295:30: note: no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::vector<std::array<int, 3> >::value_type&&’ {aka ‘std::array<int, 3>&&’} 1295 | push_back(value_type&& __x) | ~~~~~~~~~~~~~^~~ answer.code:38:19: error: no match for ‘operator[]’ (operand types are ‘std::array<int, 3>’ and ‘int’) 38 | int X1 = c[1], L1 = c[2]; | ^ answer.code:39:20: error: ‘L1’ was not declared in this scope; did you mean ‘X1’? 39 | if (sum <= L1) { | ^~ | X1 /usr/include/c++/13/bits/stl_vector.h: In instantiation of ‘constexpr std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >]’: /usr/include/c++/13/bits/stl_vector.h:528:7: required from here /usr/include/c++/13/bits/stl_vector.h:367:49: error: invalid use of incomplete type ‘struct std::array<int, 3>’ 367 | _M_impl._M_end_of_storage - _M_impl._M_start); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/13/bits/uses_allocator_args.h:38, from /usr/include/c++/13/bits/memory_resource.h:41, from /usr/include/c++/13/string:58, from /usr/include/c++/13/bits/locale_classes.h:40, from /usr/include/c++/13/bits/ios_base.h:41, from /usr/include/c++/13/ios:44, from /usr/include/c++/13/ostream:40, from /usr/include/c++/13/iostream:41, from answer.code:1: /usr/include/c++/13/tuple:2005:45: note: declaration of ‘struct std::array<int, 3>’ 2005 | template<typename _Tp, size_t _Nm> struct array; | ^~~~~ /usr/include/c++/13/bits/stl_vector.h: In instantiation of ‘constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::array<int, 3>; _Alloc = std::allocator<std::array<int, 3> >; reference = std::array<int, 3>&; size_type = long unsigned int]’: answer.code:37:27: required from here /usr/include/c++/13/bits/stl_vector.h:1126:41: error: invalid use of incomplete type ‘struct std::array<int, 3>’ 1126 | return *(this->_M_impl._M_start + __n); | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ /usr/include/c++/13/tuple:2005:45: note: declaration of ‘struct std::array<int, 3>’ 2005 | template<typename _Tp, size_t _Nm> struct array; | ^~~~~ In file included from /usr/include/c++/13/string:48: /usr/include/c++/13/bits/stl_iterator.h: In instantiation of ‘constexpr typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&) [with _Iterator = std::array<int, 3>*; _Container = std::vector<std::array<int, 3> >; typename __normal_iterator<_Iterator, _Container>::difference_type = long int]’: /usr/include/c++/13/bits/stl_algo.h:1948:22: required from ‘constexpr void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<array<int, 3>*, vector<array<int, 3> > >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’ /usr/include/c++/13/bits/stl_algo.h:4861:18: required from ‘constexpr void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<array<int, 3>*, vector<array<int, 3> > >]...