# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282786 | 2020-08-24T22:48:00 Z | doowey | Global Warming (CEOI18_glo) | C++14 | 5 ms | 5248 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const ll inf = (ll)1e10; const int N = (int)2e5 + 10; vector<pii> qq[N]; int main(){ fastIO; freopen("in.txt", "r", stdin); int n; ll x; cin >> n >> x; vector<ll> v(n); for(int i = 0 ; i < n; i ++ ){ cin >> v[i]; } vector<ll> q; ll c; int id; int res = 0; for(int i = 0 ; i < n; i ++ ){ c = v[i] - x; id = lower_bound(q.begin(), q.end(), c) - q.begin(); if(id == q.size()){ q.push_back(c); } else{ q[id] = c; } qq[i+1].push_back(mp(c, id+1)); res = max(res, id + 1); } vector<ll> g = {}; int l, r, mid; for(int i = n - 1; i >= 0; i -- ){ l = 0, r = g.size(); while(l < r){ mid = (l + r) / 2; if(g[mid] > v[i]){ l = mid + 1; } else{ r = mid; } } if(l == g.size()){ g.push_back(v[i]); } else{ g[l] = v[i]; } for(auto x : qq[i]){ l = 0, r = g.size(); while(l + 1 < r){ mid = (l + r) / 2; if(g[mid] > x.fi) l = mid; else r = mid; } res = max(res, l + (g[l]>x.fi) + x.se); } } cout << res << "\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5248 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 5120 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |