QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#721093#9528. New Energy Vehiclezzfs#RE 0ms3648kbC++14881b2024-11-07 15:12:352024-11-07 15:12:35

Judging History

This is the latest submission verdict.

  • [2024-11-07 15:12:35]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 3648kb
  • [2024-11-07 15:12:35]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+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;
}

详细

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
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: