QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#687165 | #9528. New Energy Vehicle | xianyu | WA | 59ms | 9708kb | C++14 | 1.7kb | 2024-10-29 17:29:43 | 2024-10-29 17:29:47 |
Judging History
answer
#include<iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
#include<unordered_map>
#include<iomanip>
#include<cassert>
#include<array>
#define fi first
#define se second
#define endl '\n'
#define pb push_back
#define ep emplace_back
#define debug(x) cout<<x<<'\n'
#define RES cout<<res<<'\n'
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define me(a,x) memset(a,x,sizeof(a))
#define L(i,j,k) for(int i=(j);i<=(k);++i)
#define R(i,j,k) for(int i=(j);i>=(k);--i)
#define r23 cout<<233<<endl;return;
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<PII,int> PIII;
typedef unsigned long long ull;
const int N=1e5+5,P=131,mod=998244353;
int a[N],b[N];
int x[N],t[N];
int nx[N],mp[N];
void solve(){
int n,m;cin>>n>>m;
L(i,1,n)cin>>a[i],b[i]=a[i];
L(i,1,m)cin>>x[i]>>t[i];//位置 型号
me(mp,m+1);
R(i,m,1){
nx[i]=mp[t[i]];
mp[t[i]]=i;
}
priority_queue<PII,vector<PII>,greater<PII>> q;
L(i,1,n)q.push({mp[i],i});//充电位置 序号id
int res=0,k=1;
while(!q.empty()){
auto tt=q.top();
q.pop();
int pos=tt.fi,id=tt.se;
int dis=x[k]-res;//距离下一个充电站距离
if(k<=m&&a[id]>=dis){
a[id]-=dis;
res+=dis;
a[t[k]]=b[t[k]];
q.push({nx[k],t[k]});
if(id!=t[k])q.push({pos,id});
k++;
}else{
res+=a[id];
a[id]=0;
}
}
RES;
}
// 4 3 2 2 4 1 3
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6448kb
input:
2 3 1 3 3 3 8 1 2 2 5 2 1 2 2 1
output:
12 9
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 6604kb
input:
6 3 2 2 2 2 6 1 7 1 2 2 3 3 2 1 6 2 2 3 2 2 5 1 7 2 9 1 2 2 3 3 2 1 6 2 1 1 999999999 1000000000 1 1 1 1000000000 1000000000 1
output:
9 11 4 11 999999999 2000000000
result:
ok 6 lines
Test #3:
score: -100
Wrong Answer
time: 59ms
memory: 9708kb
input:
10 230 8042 599 1039 69 1011 1366 824 14117 1523 806 5002 332 55 3769 996 359 1040 255 1135 3454 3609 6358 2509 3695 8785 3890 1304 3394 14611 33 89 2245 508 22 1043 10411 628 1279 714 903 585 7413 5099 845 148 4689 2110 8683 1613 143 3263 2599 110 244 3297 4742 1571 425 1822 15692 572 9397 328 1691...
output:
1543020 1578939 1155230 1527381 1547404 1504786 1051729 1548178 788372 1072253
result:
wrong answer 3rd lines differ - expected: '1526016', found: '1155230'