#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][j]]=++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")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
23800 KB |
Output is correct |
2 |
Correct |
28 ms |
23800 KB |
Output is correct |
3 |
Correct |
29 ms |
23800 KB |
Output is correct |
4 |
Incorrect |
29 ms |
23800 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
23800 KB |
Output is correct |
2 |
Correct |
28 ms |
23800 KB |
Output is correct |
3 |
Correct |
29 ms |
23800 KB |
Output is correct |
4 |
Incorrect |
29 ms |
23800 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
23800 KB |
Output is correct |
2 |
Correct |
28 ms |
23800 KB |
Output is correct |
3 |
Correct |
29 ms |
23800 KB |
Output is correct |
4 |
Incorrect |
29 ms |
23800 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
23800 KB |
Output is correct |
2 |
Correct |
28 ms |
23800 KB |
Output is correct |
3 |
Correct |
29 ms |
23800 KB |
Output is correct |
4 |
Incorrect |
29 ms |
23800 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |