# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169985 | 2019-12-23T14:03:05 Z | mhy908 | Global Warming (CEOI18_glo) | C++14 | 77 ms | 5540 KB |
#include <bits/stdc++.h> #define pb push_back #define mp make_pair #define F first #define S second using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<LL, LL> pll; const LL llinf=9000000000000000000; const int inf=2000000000; int n; LL x, arr[200010]; vector<LL> lis, lds; int dplis[200010], dplds[200010], ans; LL maxlis[200010], minlds[200010]; int main() { scanf("%d %lld", &n, &x); for(int i=1; i<=n; i++)scanf("%d", &arr[i]); for(int i=1; i<=n; i++){ auto it=lower_bound(lis.begin(), lis.end(), arr[i]); if(it==lis.end())lis.pb(arr[i]); else *it=arr[i]; dplis[i]=lower_bound(lis.begin(), lis.end(), arr[i+1]+x-1)-lis.begin(); } ans=dplis[n]; for(int i=n; i>=1; i--){ auto it=lower_bound(lds.begin(), lds.end(), -arr[i]); if(it==lds.end())lds.pb(-arr[i]); else *it=-arr[i]; dplds[i]=lds.size(); } ans=max(dplis[n], dplds[1]); for(int i=1; i<n; i++){ ans=max(ans, dplis[i]+dplds[i+1]); } printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 77 ms | 3456 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 19 ms | 1144 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 35 ms | 1912 KB | Output is correct |
2 | Correct | 36 ms | 1924 KB | Output is correct |
3 | Correct | 69 ms | 3448 KB | Output is correct |
4 | Correct | 50 ms | 5540 KB | Output is correct |
5 | Correct | 25 ms | 2928 KB | Output is correct |
6 | Correct | 43 ms | 5520 KB | Output is correct |
7 | Correct | 44 ms | 5068 KB | Output is correct |
8 | Correct | 30 ms | 1904 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |