General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
170962914 Practice:
silenttkillerr
1712C - 49 C++17 (GCC 7-32) Wrong answer on test 2 78 ms 148 KB 2022-09-05 18:15:57 2022-09-05 18:15:58
→ Source
#include<bits/stdc++.h>
#include<cmath>
#include<string.h>
#define fast ios_base::sync_with_stdio(0),cin.tie(0)
#define ll long long
using namespace std;
int main()
{
    fast;
    int t=1;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>vec;
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            vec.push_back(x);
        }
        int prev=INT_MAX;
        int count=0;
        set<int>deleted;
        map<int,int>right_most;
        for(int i=vec.size()-1;i>=0;i--)
        {
            right_most[vec[i]]=max(right_most[vec[i]],i);
        }
        for(int i=vec.size()-1;i>=0;i--)
        {
            if(vec[i]<=prev)
            {
                prev=vec[i];
            }
            else
            {
                for(int j=i;j>=0;j--)
                {
                    int a=vec[j];
                    if(deleted.find(a)==deleted.end())
                    {
                        count++;
                        deleted.insert(a);
                        if(right_most[a]>i)
                        {
                            j=right_most[i]+1;
                        }
                    }
                }
            }
        }
        cout<<count<<endl;

    } 
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details