QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#682917 | #9528. New Energy Vehicle | rrt517 | Compile Error | / | / | C++23 | 1.4kb | 2024-10-27 17:54:43 | 2024-10-27 17:54:43 |
Judging History
This is the latest submission verdict.
- [2024-10-27 17:54:43]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-27 17:54:43]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
struct Compare
{
bool operator()(pair<long long,int> a,pair<long long,int> b)
{
return a.first<b.first;
}
};
void solve()
{
int n,m;
cin>>n>>m;
vector<long long> a(n+1),e(n+1),x(m+1),t(m+1);
vector<vector<long long>>pos(n+1);
priority_queue<pair<long long,int>,Compare>que;
for(int i=1;i<=n;i++)
{
cin>>e[i];
a[i]=e[i];
que.push(make_pair(1e18,i));
}
for(int i=1;i<=m;i++)
{
cin>>x[i]>>t[i];
que.push(make_pair(x[i],t[i]));
pos[t[i]].push_back(x[i]);
}
for(int i=1;i<=n;i++)
pos[i].push_back(1e18);
long long cur=0;
for(int i=1;i<=m;i++)
{
while(!que.empty() and cur<x[i])
{
auto [p,id]=que.top();
if(p<=cur)
{
que.pop();
continue;
}
long long delta=min(x[i]-cur,a[id]);
cur+=delta;
a[id]-=delta;
if(a[id]==0)que.pop();
}
if(cur<x[i])break;
a[t[i]]=e[t[i]];
long long p=*upper_bound(pos[t[i]].begin(),pos[t[i]].end(),cur);
que.push(make_pair(p,t[i]));
}
for(int i=1;i<=n;i++)
cur+=a[i];
cout<<cur<<endl;
}
int main()
{
ios::sync_with_stdio(false);
int T;
cin>>T;
for(int i=1;i<=T;i++)solve();
return 0;
}
// struct Compare
// {
// bool operator()(pair<long long,int> a,pair<long long,int> b)
// {
// return a.first>b.first;
// }
// };
// priority_queue<pair<long long,int>,Compare>que;
Details
answer.code: In function ‘void solve()’: answer.code:16:51: error: no type named ‘value_type’ in ‘struct Compare’ 16 | priority_queue<pair<long long,int>,Compare>que; | ^ answer.code:16:51: error: template argument 3 is invalid answer.code:21:21: error: request for member ‘push’ in ‘que’, which is of non-class type ‘int’ 21 | que.push(make_pair(1e18,i)); | ^~~~ answer.code:26:21: error: request for member ‘push’ in ‘que’, which is of non-class type ‘int’ 26 | que.push(make_pair(x[i],t[i])); | ^~~~ answer.code:34:28: error: request for member ‘empty’ in ‘que’, which is of non-class type ‘int’ 34 | while(!que.empty() and cur<x[i]) | ^~~~~ answer.code:36:41: error: request for member ‘top’ in ‘que’, which is of non-class type ‘int’ 36 | auto [p,id]=que.top(); | ^~~ answer.code:39:37: error: request for member ‘pop’ in ‘que’, which is of non-class type ‘int’ 39 | que.pop(); | ^~~ answer.code:45:41: error: request for member ‘pop’ in ‘que’, which is of non-class type ‘int’ 45 | if(a[id]==0)que.pop(); | ^~~ answer.code:50:21: error: request for member ‘push’ in ‘que’, which is of non-class type ‘int’ 50 | que.push(make_pair(p,t[i])); | ^~~~