This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define boost() cin.tie(0), cin.sync_with_stdio(0)
const int MN = 300005;
int n, d, a[MN], ans = 1, bit[MN];
vector<int> xs;
map<int, int> mp;
void upd(int x, int val) {
for (int i = x; i < MN; i += i & -i) bit[i] = max(bit[i], val);
}
int qry(int x) {
int ret = 0;
for (int i = x; i > 0; i -= i & -i) ret = max(ret, bit[i]);
return ret;
}
int32_t main() {
boost();
cin >> n >> d;
for (int i = 1; i <= n; i++) cin >> a[i], xs.push_back(a[i]);
sort(xs.begin(), xs.end());
xs.erase(unique(xs.begin(), xs.end()), xs.end());
for (int i = 0; i < xs.size(); i++) mp[xs[i]] = i + 1;
for (int i = 1; i <= n; i++) {
int tmp = qry(mp[a[i]] - 1) + 1;
ans = max(ans, tmp);
upd(mp[a[i]], tmp);
}
printf("%lld\n", ans);
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int32_t main()':
Main.cpp:35:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int i = 0; i < xs.size(); i++) mp[xs[i]] = i + 1;
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |