QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#696313 | #9528. New Energy Vehicle | travel# | WA | 1ms | 5640kb | C++20 | 929b | 2024-10-31 22:05:29 | 2024-10-31 22:05:31 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5+9;
int n,m,s,k;
struct{
int s,i;
}b[N];
int a[N],x[N];
void solve() {
int sum = 0;
cin>>n>>m;
for(int i = 1;i <= n;i++){
cin>>a[i];
sum+=a[i];
x[i]=a[i];
}
for(int i = 1;i <= m;i++){
cin>>b[i].s>>b[i].i;
}
int l = 1, r = 1, now = 0;
for(int i = 1;i <= m;i++){
// while(r<=m&&now+sum>=b[r].s)
// r++;
int d = b[i].s-now;
for(l=max(l,i);d>0&&l<=m;l++)
{
if(d<=a[b[l].i]){
sum-=d;
a[b[l].i]-=d;
d=0;
break;
}
sum-=a[b[l].i];
d-=a[b[l].i];
a[b[l].i]=0;
}
if(d>a[b[i].i])
sum=sum+x[b[i].i]-d;
else
sum=sum+x[b[i].i]-a[b[i].i];
a[b[i].i]=x[b[i].i];
now=b[i].s;
}
now+=sum;
cout<<now<<"\n";
}
signed main(){
std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int _=1; cin>>_;
while(_--)
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5640kb
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: 0ms
memory: 3656kb
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 10 11 1999999998 2000000000
result:
wrong answer 3rd lines differ - expected: '4', found: '10'