QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#684633#9528. New Energy VehiclevisionWA 2ms11728kbC++202.0kb2024-10-28 14:52:212024-10-28 14:52:21

Judging History

This is the latest submission verdict.

  • [2024-10-28 14:52:21]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 11728kb
  • [2024-10-28 14:52:21]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
#define lson k<<1
#define rson (k<<1)|1
#define debug cout<<666<<endl;
using namespace std;
const int N=1e6+5;
int a[N];
int b[N];
pair<int,int>p[N];
int ne[N];
int w[N];
void vision()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    for(int i=1;i<=m;i++){
        cin>>p[i].first>>p[i].second;
    }
    for(int i=m+1;i<=m+n;i++){
        p[i].first=p[m].first+i-m;
        p[i].second=i-m;
        w[i-m]=i;
        ne[i]=i;
    }
    set<int>st;
    map<int,int>mp;
    for(int i=1;i<=n+m;i++){
        if(mp[p[i].second]==0){
            st.insert(i);
            mp[p[i].second]=1;
        }
    }
    for(int i=m;i>=1;i--){
        ne[i]=w[p[i].second];
        w[p[i].second]=i;
    }
    // cout<<ne[1]<<" ";
    int now=0;
    // for(auto it:st)cout<<it<<" ";
    for(int i=1;i<=m;i++){
        while(st.size()>0){
            if(now<p[i].first){
                auto it=*st.begin();
                int tmp=p[it].second;
                if(now+a[tmp]<p[i].first){
                    now+=a[tmp];
                    a[tmp]=0;
                    st.erase(st.begin());
                }
                else {
                    int ned=p[i].first-now;
                    a[tmp]-=ned;
                    now=p[i].first;
                    if(tmp==p[i].second)st.erase(st.begin());
                }
            }
            else {
                 break;
            }
        }
        if(now<p[i].first)break;
        // cout<<i<<":"<<p[i].second<<" ";
        // for(auto it:st)cout<<it<<" ";

        st.insert(ne[i]);
        a[p[i].second]=b[p[i].second];
    }
    // cout<<now<<" ";
    for(int i=1;i<=n;i++){
        cout<<a[i]<<":";
        now+=a[i];
    }
    cout<<now<<"\n";
    return ;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t=1;
    cin>>t;
    while(t--){
        vision();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 11728kb

input:

2
3 1
3 3 3
8 1
2 2
5 2
1 2
2 1

output:

3:0:1:12
5:2:9

result:

wrong answer 1st lines differ - expected: '12', found: '3:0:1:12'