# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
848149 | KN200711 | Global Warming (CEOI18_glo) | C++14 | 40 ms | 4064 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;
int main() {
int N, d;
scanf("%d %d", &N, &d);
vector<int> arr(N);
for(int i=0;i<N;i++) scanf("%d", &arr[i]);
vector<int> wo, wi;
wo.clear();
wi.clear();
for(int i=0;i<N;i++) {
if(wo.size() == 0 || wo.back() < arr[i]) wo.push_back(arr[i]);
else {
int c = lower_bound(wo.begin(), wo.end(), arr[i]) - wo.begin();
wo[c] = arr[i];
}
if(wi.size() == 0 || wi.back() < arr[i] - d) {
wi.push_back(arr[i] - d);
int p = wi.size();
wo[p - 1] = min(wo[p-1], wi[p-1]);
}
else {
int c = lower_bound(wi.begin(), wi.end(), arr[i] - d) - wi.begin();
wi[c] = arr[i] - d;
wo[c] = min(wo[c], wi[c]);
}
}
printf("%d\n", wo.size());
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... |