# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060111 | ali2241 | Global Warming (CEOI18_glo) | C++17 | 2061 ms | 4264 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>
#define int long long
using namespace std;
void fun() {
int n, x;
cin >> n >> x;
int arr[n];
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
int mx = 0;
for (int i = -x; i <= x; ++i) {
vector<int> lis;
for (int j = 0; j < n; ++j) {
int a = arr[j], b = arr[j] + i;
if (a < b) {
swap(a, b);
}
int p1 = lower_bound(lis.begin(), lis.end(), a) - lis.begin();
if (p1 == lis.size() or lis.empty()) {
lis.push_back(a);
}
else {
lis[p1] = a;
}
int p2 = lower_bound(lis.begin(), lis.end(), b) - lis.begin();
if (p2 == lis.size()) {
lis.push_back(b);
}
else {
lis[p2] = b;
}
}
mx = max(mx, (int)lis.size());
}
cout << mx << "\n";
}
int32_t main() {
fun();
}
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... |