QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#683335 | #9528. New Energy Vehicle | potential | WA | 1ms | 9780kb | C++20 | 883b | 2024-10-27 20:18:36 | 2024-10-27 20:18:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
typedef pair<int,int> pii;
const int N=3e5+10;
int b[N];
int x[N],t[N];
int pp[N];
void solve(){
int n,m;
cin>>n>>m;
int now=0;
for(int i=1;i<=n;i++) pp[i]=0;
for(int i=1;i<=n;i++){
cin>>b[i];
now+=b[i];
}
for(int i=1;i<=m;i++){
cin>>x[i]>>t[i];
}
int pre=0;
for(int i=1;i<=m;i++){
if(now>x[i]){
now+=min(x[i]-max(pre,pp[t[i]]),b[t[i]]);
pre+=min(x[i]-pre,b[t[i]]);
pp[t[i]]=x[i];
}
else{
break;
}
// cout<<i<<" "<<now<<"\n";
}
cout<<now<<"\n";
}
signed main(){
IOS
int T=1;
cin>>T;
while(T--){
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 9780kb
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
Wrong Answer
time: 1ms
memory: 9708kb
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:
6 11 4 11 999999999 1000000000
result:
wrong answer 1st lines differ - expected: '9', found: '6'