QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#700355#9528. New Energy Vehiclesw7777#WA 1ms5780kbC++201.2kb2024-11-02 12:47:152024-11-02 12:47:16

Judging History

This is the latest submission verdict.

  • [2024-11-02 12:47:16]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5780kb
  • [2024-11-02 12:47:15]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 2e5+10;
struct chong{
    int dis;
    int x;
    bool operator < (const chong &b) const{
        return dis < b.dis;
    }
}chg[maxn];
int a[maxn];
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        int n,m;
        cin>>n>>m;
        int ans = 0;
        for(int i = 1;i<=n;i++){
            cin>>a[i];
            ans += a[i];
        }
        for(int i = 1;i<=m;i++){
            cin>>chg[i].dis>>chg[i].x;
        }
        sort(chg+1,chg+m+1);
        int di = 0;
        int add = 0;
        for(int i = 1;i<=m&&ans+add>=chg[i].dis;i++){
            int dis = chg[i].dis;
            int x= chg[i].x;
            //cout<<dis<<" "<<x<<" "<<a[x]<<endl;
            if(dis - di > a[x]){
                di += a[i];
                add += a[i];
                //cout<<di<<" "<<add<<endl;
            }
            else{
                add += dis - di;
                di = dis;
            }
            //cout<<di<<" "<<add<<endl;
        }
        cout<<ans+add<<endl;
    }
    
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5716kb

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: 1ms
memory: 5780kb

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'