QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#686769 | #9528. New Energy Vehicle | Hqwq | RE | 0ms | 3580kb | C++20 | 891b | 2024-10-29 15:37:00 | 2024-10-29 15:37:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int T,n,m;
long long a[100010];
long long last[100010];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>T;
while(T--){
long long sum=0;
long long cnt=0;
cin>>n>>m;
for (int i=1;i<=n;i++) {
cin>>a[i];
sum+=a[i];
last[i]=0;
}
long long lx=0;
for (int i=1;i<=m;i++){
long long x,t;
cin>>x>>t;
cnt+=x-lx;
if (sum<x) break;
long long tmp=min(cnt,x-last[t]);
if (tmp>=a[t]) {
sum+=a[t];
cnt-=a[t];
}
else{
sum+=tmp;
cnt-=tmp;
}
last[t]=x;
lx=x;
}
cout<<sum<<'\n';
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
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: -100
Runtime Error
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