QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#721147 | #9528. New Energy Vehicle | zzfs# | RE | 0ms | 3652kb | C++14 | 881b | 2024-11-07 15:24:19 | 2024-11-07 15:24:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5+5;
int a[N];
int p[N];
void solve()
{
int n,m;
cin>>n>>m;
int sum = 0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum += a[i];
p[i] = 0;
}
int len = 0;
int x,y;
for(int i=1;i<=m;i++){
cin>>x>>y;
if(x-len>sum){
cout<<len+sum<<'\n';
return ;
}
int acm = a[y] - x + p[y];
if(acm<0)acm = 0;
int 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 ;
}
signed main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int t = 1;
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: 3652kb
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