# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
476510 | RambaXGorilla | Global Warming (CEOI18_glo) | C++17 | 86 ms | 5360 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<cstdio>
#include<climits>
#include<algorithm>
using namespace std;
int N, X;
int temps[200010];
int incSubs[200010];
int decSubs[200010];
int lengths[200010];
int main(){
scanf("%d%d",&N,&X);
for(int i = 0;i < N;i++){
scanf("%d",&temps[i]);
}
fill(incSubs, incSubs + N, INT_MAX);
for(int i = 0;i < N;i++){
int pos = lower_bound(incSubs, incSubs + N, temps[i]) - incSubs;
incSubs[pos] = temps[i];
lengths[i] = pos + 1;
}
int longest = 0;
fill(decSubs, decSubs + N, INT_MAX);
for(int i = N - 1;i > -1;i--){
int pos1 = lower_bound(decSubs, decSubs + N, X - temps[i]) - decSubs;
longest = max(longest, lengths[i] + pos1);
int pos2 = lower_bound(decSubs, decSubs + N, -temps[i]) - decSubs;
decSubs[pos2] = -temps[i];
}
printf("%d",longest);
}
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... |