QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#692431 | #9528. New Energy Vehicle | wangshengzhe# | Compile Error | / | / | C++14 | 1.7kb | 2024-10-31 14:29:45 | 2024-10-31 14:30:41 |
Judging History
This is the latest submission verdict.
- [2024-10-31 14:30:41]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-31 14:29:45]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 1e5+5;
const int mod = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double ef = 1e-12;
const double PI = acos(-1);
#define sc(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define rep(i,a, b) for(int i = a;i<=b;i++)
#define rep2(i,a, b) for(int i = a;i>=b;i--)
#define pb push_back
#define ll long long
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int now[N];
map<int,int>nxt,tp;
ll a[N];
int main(int argc, char** argv)
{
int T;
cin>>T;
while(T--){
int n,m;
sc(n);sc(m);
rep(i,1,n)sl(a[i]);
vector<pair<int,int> >v;
rep(i,1,m){
int x,t;
sc(x);sc(t);
tp[x]=t;
v.pb({x,t});
}
rep(i,1,n)now[i]=-1;
sort(v.begin(),v.end());
rep2(i,m-1,0){
if(now[v[i].second]!=-1)nxt[i]=now[v[i].second];
now[v[i].second]=i;
}
priority_queue<pair<int,pair<int,int> > >q;
rep(i,1,n){
if(now[i]!=-1)q.push({-now[i],{a[i],i}});
else q.push({-1e9-1,{a[i],i}});
}
ll nw=0;int j=0;
while(!q.empty()){
int u=q.top().first;
int w=q.top().second.first;
int tp=q.top().second.second;
q.pop();
//cout<<nw<<" "<<u<<" "<<w<<endl;
if(j<m&&nw+w>=v[j].first){
// cout<<"?"<<u<<" "<<tp<<" "<<v[j].second<<endl;
if(nw+w-v[j].first&&tp!=v[j].second){
q.push({u,{nw+w-v[j].first,tp}});
}//如果不是当前的可以回收,否则不行
if(nxt.count(j))
q.push({-nxt[j],{a[v[j].second],v[j].second}});
else q.push({-1e9-1,{a[v[j].second],v[j].second}});
nw=v[j].first;
j++;
}
else{
nw+=w;
continue;
}
}
cout<<nw<<endl;
}
return 0;
}
Details
answer.code:8:17: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘4557430888798830399’ to ‘1061109567’ [-Woverflow] 8 | const int INF = 0x3f3f3f3f3f3f3f3f; | ^~~~~~~~~~~~~~~~~~ answer.code: In function ‘int main(int, char**)’: answer.code:46:36: error: narrowing conversion of ‘-1.000000001e+9’ from ‘double’ to ‘int’ [-Wnarrowing] 46 | else q.push({-1e9-1,{a[i],i}}); | ~~~~~~^~~~~~~~~~~~~~~~~~~ answer.code:62:44: error: narrowing conversion of ‘-1.000000001e+9’ from ‘double’ to ‘int’ [-Wnarrowing] 62 | else q.push({-1e9-1,{a[v[j].second],v[j].second}}); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | #define sc(x) scanf("%d",&x) | ~~~~~^~~~~~~~~ answer.code:28:17: note: in expansion of macro ‘sc’ 28 | sc(n);sc(m); | ^~ answer.code:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | #define sc(x) scanf("%d",&x) | ~~~~~^~~~~~~~~ answer.code:28:23: note: in expansion of macro ‘sc’ 28 | sc(n);sc(m); | ^~ answer.code:12:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | #define sl(x) scanf("%lld",&x) | ~~~~~^~~~~~~~~~~ answer.code:29:27: note: in expansion of macro ‘sl’ 29 | rep(i,1,n)sl(a[i]); | ^~ answer.code:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | #define sc(x) scanf("%d",&x) | ~~~~~^~~~~~~~~ answer.code:33:25: note: in expansion of macro ‘sc’ 33 | sc(x);sc(t); | ^~ answer.code:11:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | #define sc(x) scanf("%d",&x) | ~~~~~^~~~~~~~~ answer.code:33:31: note: in expansion of macro ‘sc’ 33 | sc(x);sc(t); | ^~