Pagini recente » Cod sursa (job #1184143) | Cod sursa (job #1163254) | Cod sursa (job #2528885) | Cod sursa (job #2767046) | Cod sursa (job #2744255)
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
#define LSB(a) ((-a) & a)
using namespace std;
#ifdef LOCAL
#define read() ifstream fin("date.in.txt");
#else
#define read() ifstream fin("scmax.in"); ofstream fout("scmax.out");
#endif // LOCAL
const int N = 100005;
int n, AIB[N];
int v[N];
map<int,int> idx;
set<int> vals;
int last[N];
bool cmp(int a, int b) {
return v[a] < v[b];
}
void update(int pos, int act) {
while(pos <= n) {
if(last[pos] < act){
++AIB[pos];
last[pos] = act;
}
pos += LSB(pos);
}
}
int main() {
read();
fin >> n;
n = 2 * n;
for (int i = 1; i <= n; ++i) {
fin >> v[i];
vals.insert(v[i]);
}
int p = 1;
for (int x : vals)
idx[x] = p++;
for (int i = 1; i <= n; ++i) {
update(idx[v[i]], v[i]);
/*for (int j = 1; j <= n; ++j)
cout << AIB[j] << " ";
cout << '\n';
*/
}
int mx = 0;
for (int i = 1; i <= n; ++i)
mx = max(mx, AIB[i]);
#ifdef LOCAL
cout << mx << '\n';
#else
fout << mx << '\n';
#endif // LOCAL
return 0;
}