QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749133 | #9528. New Energy Vehicle | bluejellyfish | Compile Error | / | / | C++23 | 1.7kb | 2024-11-14 22:47:26 | 2024-11-14 22:47:26 |
Judging History
This is the latest submission verdict.
- [2024-11-14 22:47:26]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-14 22:47:26]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
using pii = pair<int,int>;
const int inf = 0x3f3f3f3f;
struct hui{
int x,y;
// bool operator <(const hui & k) const {
// return k.x > x;
// }
};
void miss() {
int n,m;
cin >> n >> m;
vector<int>ai(n + 1),bi(n + 1);
int tot = 0;
for(int i = 1; i <= n; i++) {
cin >> ai[i];
bi[i] = ai[i];
tot += ai[i];
}
hui q[m + 1];
for(int i = 1; i <= m; i++) {
cin >> q[i].x >> q[i].y;
}
q[0].x = q[0].y = 0;
queue<int>a[n + 1];
for(int i = 1; i <= m; i++) {
a[q[i].y].push(i);
}
for(int i = 1; i <= n; i++) {
a[i].push(inf);
}
priority_queue<pii,vector<pii>,greater<>> qq;
for(int i = 1; i <= n; i++) {
qq.push({a[i].front(),i});
a[i].pop();
}
for(int i = 1; i <= m; i++) {
int len = q[i].x - q[i - 1].x;
queue<pii>qi;
if(tot < len) {
cout << q[i - 1].x + tot << endl;
return;
}
while(len) {
if(ai[qq.top().y] < len) {
tot -= ai[qq.top().y];
len -= ai[qq.top().y];
auto it = qq.top();qq.pop();
ai[it.y] = 0;
it.x = a[it.y].front();
qi.push(it);
}else {
tot -= len;
auto it = qq.top();qq.pop();
ai[it.y] -= len;
len = 0;
it.x = a[it.y].front();
qi.push(it);
}
}
while(qi.size()) {
while(ai[qi.front()] == int) qi.pop();
qq.push(qi.front());qi.pop();
}
tot += bi[q[i].y] - ai[q[i].y];
ai[q[i].y] = bi[q[i].y];
}
int ans = q[m].x;
for(int i = 1; i <= n; i++) {
ans += ai[i];
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int T = 1;
cin >> T;
while(T--) miss();
//system("pause");
}
Details
answer.code: In function ‘void miss()’: answer.code:66:33: error: no match for ‘operator[]’ (operand types are ‘std::vector<long long int>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type’ {aka ‘std::pair<long long int, long long int>’}) 66 | while(ai[qi.front()] == int) qi.pop(); | ^ 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, from answer.code:1: /usr/include/c++/13/bits/stl_vector.h:1123:7: note: candidate: ‘constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]’ 1123 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1123:28: note: no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type’ {aka ‘std::pair<long long int, long long int>’} to ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} 1123 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/13/bits/stl_vector.h:1142:7: note: candidate: ‘constexpr std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]’ 1142 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/13/bits/stl_vector.h:1142:28: note: no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type’ {aka ‘std::pair<long long int, long long int>’} to ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} 1142 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ answer.code:3:13: error: expected primary-expression before ‘long’ 3 | #define int long long | ^~~~ answer.code:66:49: note: in expansion of macro ‘int’ 66 | while(ai[qi.front()] == int) qi.pop(); | ^~~ answer.code:66:48: error: expected ‘)’ before ‘long’ 66 | while(ai[qi.front()] == int) qi.pop(); | ~ ^ | ) answer.code:66:52: error: expected unqualified-id before ‘)’ token 66 | while(ai[qi.front()] == int) qi.pop(); | ^