제출 #781381

#제출 시각아이디문제언어결과실행 시간메모리
781381joelgun14Global Warming (CEOI18_glo)C++17
17 / 100
116 ms8772 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; int t[n + 1]; for(int i = 1; i <= n; ++i) { cin >> t[i]; } // find prefix lis/suffix lis, nanti cari yg max di mana // suffix lis -> lds dr belakang // prefix lis -> lis dr depan int pref[n + 1], suff[n + 2]; pref[0] = 0, suff[n + 1] = 0; set<int> s; for(int i = 1; i <= n; ++i) { if(s.lower_bound(t[i]) != s.end()) { s.erase(s.lower_bound(t[i])); s.insert(t[i]); } else { s.insert(t[i]); } pref[i] = s.size(); } for(int i = 1; i <= n; ++i) { t[i] = -t[i]; } s.clear(); for(int i = n; i >= 1; --i) { if(s.lower_bound(t[i]) != s.end()) { s.erase(s.lower_bound(t[i])); s.insert(t[i]); } else { s.insert(t[i]); } suff[i] = s.size(); } int out = 0; for(int i = 1; i <= n; ++i) out = max(out, pref[i] + suff[i + 1]); cout << out << endl; }
#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...