Submission #1136099

#TimeUsernameProblemLanguageResultExecution timeMemory
1136099nrg_studioGlobal Warming (CEOI18_glo)C++20
27 / 100
25 ms1068 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int,int> #define f first #define s second #define chmin(a, b) a = min(a,b) #define chmax(a, b) a = max(a,b) #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) for (int i = 0; i < (a); i++) #define all(x) x.begin(),x.end() #define v vector int main() { ios::sync_with_stdio(false); cin.tie(0); int n, d; cin >> n >> d; v<int> dp; auto doit = [&](int a) { int pos = lower_bound(all(dp),a)-dp.begin(); if (pos==dp.size()) {dp.pb(a);} else {dp[pos] = a;} }; F0R(i,n) { int a; cin >> a; doit(a); doit(a+d); } cout << dp.size() << '\n'; /* positive d: do suffix negative d: do prefix (which is same as positive d on suffix) positive d: two lis arrays one is without adding, one is with without adding: do it normally with adding: do it normally transition: look for a_i+d need to prove monotonicity of both arrays first array is easy second = min a such that lis with additions of length i (monotonic) transitions from first to second: update first array, test updated val in second array, update second array? no do better idea */ }
#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...