제출 #1310098

#제출 시각아이디문제언어결과실행 시간메모리
1310098qrnGlobal Warming (CEOI18_glo)C++20
100 / 100
45 ms8272 KiB
#include "bits/stdc++.h" using namespace std; #define intt long long #define fi first #define se second #define endl "\n" const intt mxN = 2e5+67; const intt LG = 20; const intt inf = 1e18; const intt mod = 1e9 + 7; const intt p = 997; vector<intt> a(mxN), sol(mxN, inf), sag(mxN, inf), dpL(mxN), dpR(mxN); map<intt,intt> comp; set<intt> st; intt avil = 1; void smile() { intt n, k; cin >> n >> k; for(intt i = 0; i < n; i++) { cin >> a[i]; } sol.assign(n + 1, inf); sag.assign(n + 1, inf); for(intt i = 0; i < n; i++) { intt ind = lower_bound(sol.begin(), sol.end(), a[i]) - sol.begin(); sol[ind] = a[i]; dpL[i] = ind + 1; } for(intt i = n - 1; i >= 0; i--) { intt cnt = lower_bound(sag.begin(), sag.end(), -1 * (a[i] - k)) - sag.begin(); dpR[i] = cnt + 1; intt ind = lower_bound(sag.begin(), sag.end(), -1 * a[i]) - sag.begin(); sag[ind] = -1 * a[i]; } intt ans = 0; for(intt i = 0; i < n; i++) { ans = max(ans, dpL[i] + dpR[i] - 1); } cout << ans << endl; } //ome47 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("island.in", "r", stdin); // freopen("island.out", "w", stdout) intt t = 1, buu = 1; // cin >> t; while(t--){ // cout << endl; // cout << "Case #" << buu++ << ": "; smile(); } }
#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...