# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1104163 | vjudge1 | Global Warming (CEOI18_glo) | C++17 | 36 ms | 2016 KiB |
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;
const int N = 2e5 + 3;
int ar[N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, x; cin >> n >> x;
for(int i=1; i<=n; ++i) cin >> ar[i];
int res = 1;
int dp[n+1];
dp[0] = 0;
vector<int> lis;
for(int i=1; i<=n; ++i) {
auto t = lower_bound(lis.begin(), lis.end(), ar[i]);
if(t == lis.end()) lis.emplace_back(ar[i]);
else *t = ar[i];
dp[i] = lis.size();
}
res = lis.size();
lis.clear();
for(int i=n; i>=1; --i) {
int x = lower_bound(lis.begin(), lis.end(), -ar[i] + x) - lis.begin();
res = max(res, dp[i] + x);
auto t = lower_bound(lis.begin(), lis.end(), -ar[i]);
if(t == lis.end()) lis.emplace_back(-ar[i]);
else *t = -ar[i];
}
cout << res << '\n';
return 0;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |