QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#788753#9528. New Energy VehicleCSQ#Compile Error//C++201.5kb2024-11-27 18:09:552024-11-27 18:09:56

Judging History

This is the latest submission verdict.

  • [2024-11-27 18:09:56]
  • Judged
  • [2024-11-27 18:09:55]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sz(a) (int)(a.size())

signed main()
{
    int T;
    cin>>T;
    while(T--){
        int n, m;
        cin >> n >> m;
        int sum = 0;
        vector<int>a(n),x(m),t(m),d(m+1,4e18);
        multiset<array<int,2>>bat;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum += a[i];
            bat.insert({a[i],i});
        }
        vector<int>tmp = a;

        for(int i=0;i<m;i++){
            cin>>x[i]>>t[i];
            t[i]--;
        }
        for(int i=0;i<m;i++){
            if(!i)d[i] = x[i];
            else d[i] = x[i] - x[i-1];
        }
        int ans = 0;
        for(int i=0;i<m;i++){
            while(!bat.empty() && d[i]){
                auto b = *bat.begin();
                int id = b[1];
                int mn = min(b[0],d[i]);
                //cout<<id<<" "<<mn<<" "<<d[i]<<'\n';
                a[id] -= mn;
                d[i] -= mn;
                ans += mn;
                bat.erase(bat.begin());
                if(a[id])bat.insert({a[id],i});
            }
            if(d[i])break;
            bat.erase({a[t[i]],t[i]});
            a[t[i]] = tmp[t[i]];
            bat.insert({a[t[i]],t[i]});
            if(i==m-1){
                        while(!bat.empty()){
               ans += (*bat.begin())[0];
               bat.erase(bat.begin());
             }
        }
        cout<<ans<<'\n';
    }
    return 0;

}

Details

answer.code: In function ‘int main()’:
answer.code:58:2: error: expected ‘}’ at end of input
   58 | }
      |  ^
answer.code:7:1: note: to match this ‘{’
    7 | {
      | ^