QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#750260 | #9528. New Energy Vehicle | ExFoler | WA | 0ms | 3648kb | C++20 | 1.0kb | 2024-11-15 13:43:26 | 2024-11-15 13:43:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e5+10;
LL a[N],x[N],t[N];
LL man[N];
void solve()
{
LL n,m;
cin >> n >> m;
memset(man,0,(sizeof (LL))*(n+5));
LL sum=0;
for(LL i=1;i<=n;i++)
{
cin >> a[i];
sum+=a[i];
}
for(LL i=1;i<=m;i++)
{
cin >> x[i] >> t[i];
}
LL dis=0,ans=0;
for(LL i=1;i<=m;i++)
{
LL d=x[i]-x[i-1];
dis+=d;
if(dis>sum)
{
ans=x[i-1]+(sum-(dis-d));
break;
}
LL bus=min(dis,min(x[i] - x[i - 1] -man[t[i]],a[t[i]]));
dis-=bus;
dis = max(dis , 0ll) ;
man[t[i]]=x[i];
}
if(dis<=sum) ans=x[m]+(sum-dis);
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T;
cin >> T;
while(T--)
{
solve();
}
return 0;
}
/*
1
1 4
1
1 1
2 1
3 1
4 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3648kb
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: 3632kb
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:
0 11 4 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '0'