QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#721267 | #9528. New Energy Vehicle | zzfs# | RE | 0ms | 3592kb | C++17 | 848b | 2024-11-07 15:43:30 | 2024-11-07 15:43:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
int a[N];
unordered_map<int,int> p;
void solve()
{
int n,m;
cin>>n>>m;
ll sum = 0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum += a[i];
p[i] = 0;
}
ll len = 0;
ll x;
int y;
for(int i=1;i<=m;i++){
cin>>x>>y;
if(x-len>sum){
cout<<len+sum<<'\n';
return ;
}
ll acm = a[y] - x + p[y];
if(acm<0)acm = 0;
ll res = x - len - acm;
if(res>0){
sum-=res;
sum+=a[y];
}
//sum+=a[y];
p[y] = x;
len = x;
}
cout<<x+sum<<"\n";
return ;
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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
output:
9 13 4 24