제출 #1125797

#제출 시각아이디문제언어결과실행 시간메모리
1125797vladiliusGlobal Warming (CEOI18_glo)C++20
15 / 100
2095 ms5700 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second struct ST{ vector<int> t; int n; ST(int ns){ n = ns; t.resize(4 * n); } void upd(int v, int tl, int tr, int& p, int& x){ if (tl == tr){ t[v] = max(t[v], x); return; } int tm = (tl + tr) / 2, vv = 2 * v; if (p <= tm){ upd(vv, tl, tm, p, x); } else { upd(vv + 1, tm + 1, tr, p, x); } t[v] = max(t[vv], t[vv + 1]); } void upd(int p, int x){ upd(1, 1, n, p, x); } int get(int v, int tl, int tr, int& p){ if (tl > p) return 0; if (tr <= p){ return t[v]; } int tm = (tl + tr) / 2, vv = 2 * v; return max(get(vv, tl, tm, vv), get(vv + 1, tm + 1, tr, p)); } int get(int p){ if (!p) return 0; return get(1, 1, n, p); } }; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, x; cin>>n>>x; vector<int> a(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; } auto lis = [&](vector<int> x){ ST T(n); vector<int> dp(n + 1); int ret = 0; for (int i = 1; i <= n; i++){ dp[i] = 1; for (int j = 1; j < i; j++){ if (x[j] < x[i]){ dp[i] = max(dp[i], dp[j] + 1); } } ret = max(ret, dp[i]); } return ret; }; int out = 0; for (int l = 1; l <= n; l++){ for (int r = l; r <= n; r++){ for (int d = -x; d <= x; d++){ for (int i = l; i <= r; i++){ a[i] += d; } out = max(out, lis(a)); for (int i = l; i <= r; i++){ a[i] -= d; } } } } cout<<out<<"\n"; }
#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...