QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#686769#9528. New Energy VehicleHqwqRE 0ms3580kbC++20891b2024-10-29 15:37:002024-10-29 15:37:02

Judging History

This is the latest submission verdict.

  • [2024-10-29 15:37:02]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3580kb
  • [2024-10-29 15:37:00]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

int T,n,m;
long long a[100010];
long long last[100010];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>T;
    while(T--){
        long long sum=0;
        long long cnt=0;
        cin>>n>>m;
        for (int i=1;i<=n;i++) {
            cin>>a[i];
            sum+=a[i];
            last[i]=0;
        }
        long long lx=0;
        for (int i=1;i<=m;i++){
            long long x,t;
            cin>>x>>t;
            cnt+=x-lx;
            if (sum<x) break;
            long long tmp=min(cnt,x-last[t]);
            if (tmp>=a[t]) {
                sum+=a[t];
                cnt-=a[t];
            }
            else{
                sum+=tmp;
                cnt-=tmp;
            }
            last[t]=x;
            lx=x;
        }
        cout<<sum<<'\n';
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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:


result: