# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775787 | vgoofficial | Global Warming (CEOI18_glo) | C++14 | 53 ms | 5720 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;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,x;
cin >> n >> x;
int temps[n];
for(int i = 0; i < n; i++) cin >> temps[i];
int left[n], right[n];
vector<int> magic;
magic.push_back(temps[0]);
left[0]=1;
for(int i = 1; i < n; i++) {
int lb = lower_bound(begin(magic), end(magic), temps[i])-begin(magic);
if(lb==magic.size()) {
magic.push_back(temps[i]);
} else {
magic[lb]=temps[i];
}
left[i]=lb+1;
}
vector<int> magic2;
magic2.push_back(-temps[n-1]);
right[n-1]=0;
for(int i = n-2; i >= 0; i--) {
//for(int i: magic2) cout << i << " ";
int rb = lower_bound(begin(magic2), end(magic2), -temps[i]+x)-begin(magic2);
//cout << -temps[i]+x<< " " << rb << endl;
right[i]=rb;
int insert = lower_bound(begin(magic2), end(magic2), -temps[i])-begin(magic2);
if(insert==magic2.size()) {
magic2.push_back(-temps[i]);
} else {
magic2[insert]=-temps[i];
}
}
int max = 0;
for(int i = 0; i < n; i++) {
max=std::max(max,left[i]+right[i]);
}
cout << max << endl;
}
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... |