#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e6+50;
const int mod=1e9+7;
using namespace std;
int n,i,a[nmax],rs,id,j;
set<int>s;
set<int>::iterator it;
vector<int>vc[nmax];
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n;
for(i=1;i<=n;i++)
{
cin>>a[i];
vc[a[i]].pb(i);
}
for(i=1;i<=1e6;i++)
{
if(vc[i].empty())continue;
for(j=0;j<(int)vc[i].size();j++)
{
a[vc[i][(int)vc[i].size()-j-1]=++id;
}
}
//for(i=1;i<=n;i++)cout<<a[i]<<" ";
//cout<<endl;
s.in(0),s.in(inf);
for(i=1;i<=n;i++)
{
if(i==1)
{
s.in(a[i]);
rs++;
continue;
}
it=--s.upper_bound(a[i]);
if((*it)!=a[i-1])rs++;
s.in(a[i]);
}
cout<<rs<<endl;
return 0;
}
Compilation message
money.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
money.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
money.cpp: In function 'int main()':
money.cpp:42:39: error: expected ']' before ';' token
a[vc[i][(int)vc[i].size()-j-1]=++id;
^