Submission #1112700

#TimeUsernameProblemLanguageResultExecution timeMemory
1112700raspyGlobal Warming (CEOI18_glo)C++17
17 / 100
34 ms7560 KiB
#include <bits/stdc++.h> #define int long long #define vi vector<int> #define ii pair<int, int> #define f first #define s second #define all(x) (x).begin(), (x).end() #define P 31 #define mod 1'000'000'007 #define inf 1'000'000'000'000 #define pb push_back #define str string #define sz(x) (x).size() #define vvi vector<vi> #define fun function #define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define file freopen("problemname.in", "r", stdin); freopen("pr.out", "w", stdout); #define dbg(v) cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; template <class T, int SZ> using arr = array<T, SZ>; void solve() { int n, x; cin >> n >> x; vi a(n); for (int&v:a) cin >> v; vi lis; vi dis(n); vi t; for (int i = n-1; i >= 0; i--) { int tr = -a[i]; if (t.empty() || tr > t.back()) t.pb(tr); else { int ix = lower_bound(all(t), tr)-t.begin(); t[ix] = tr; } dis[i] = t.size(); } int rez = dis[0]; for (int i = 0; i < n; i++) { if (lis.size() && lis.back() < a[i]+x) { rez = max(rez, (int)lis.size()+dis[i]); } // cout << i << " " << lis.size() << " " << dis[i] << "\n"; if (lis.empty() || a[i] > lis.back()) lis.pb(a[i]); else { int ix = lower_bound(all(lis), a[i])-lis.begin(); lis[ix] = a[i]; } } cout << rez << "\n"; } signed main() { oopt; int t = 1; // cin >> t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...