QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#679571 | #9528. New Energy Vehicle | ucup-team134# | WA | 0ms | 4096kb | C++17 | 1.3kb | 2024-10-26 17:54:21 | 2024-10-26 17:54:23 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128
using namespace std;
mt19937 rng(time(NULL));
int main()
{
ios;
int t;
cin >> t;
while(t--){
int n,m;
cin >> n >> m;
ll b=0;
vector<int> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
b+=a[i];
}
ll potrosio=0;
int p=0;
bool done=0;
pair<ll,int> nesme={0,-1};
for(int i=0;i<m;i++){
int x,t;
cin >> x >> t;
t--;
if(done)continue;
int d=x-p;
if(potrosio+d>b){
printf("%lld\n",p+b-potrosio);
done=1;
}
potrosio+=d;
if(nesme.s==t){
ll smem=potrosio-nesme.s;
ll ref;
if(smem>a[t]){
ref=a[t];
nesme.f+=smem-a[t];
}
else{
ref=smem;
}
potrosio-=ref;
}
else{
ll tokens=a[t];
if(tokens>=nesme.f){
potrosio-=nesme.f;
nesme={0,-1};
tokens-=nesme.f;
}
if(potrosio>tokens){
potrosio-=tokens;
nesme={potrosio,t};
}
else{
potrosio=0;
}
}
p=x;
}
if(!done){
printf("%lld\n",p+b-potrosio);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3812kb
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: 4096kb
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:
10 11 4 11 999999999 2000000000
result:
wrong answer 1st lines differ - expected: '9', found: '10'