Submission #760207

#TimeUsernameProblemLanguageResultExecution timeMemory
760207drdilyorLIS (INOI20_lis)C++17
0 / 100
4080 ms384 KiB
#include<bits/extc++.h> using namespace std; namespace pbds = __gnu_pbds; int main() { int n; cin >> n; vector<pair<int,int>> arr(n); for (auto& [p, x] : arr) cin >> p >> x, p--; pbds::tree<int, pbds::null_type, less<int>, pbds::rb_tree_tag, pbds::tree_order_statistics_node_update> st; for (int i = 0; i < n;i++) st.insert(i); reverse(arr.begin(), arr.end()); for (auto &[p, x] : arr) { auto it = st.find_by_order(p); p = *it+1; st.erase(it); } reverse(arr.begin(), arr.end()); #ifdef ONPC for (auto &[p, x] : arr) { cout << p << ' ' << x << endl; } cout <<"---" << endl; #endif vector<int> pot(n+1); for (auto [p, x] : arr) { pot[p] = x; vector<int> dp(pot.size()); for (int i = 0; i < (int)pot.size(); i++) { for (int j = 0; j < i ;j++) { if (pot[j] < pot[i]) dp[i] = max(dp[i], dp[j]); } dp[i]++; } cout << *max_element(dp.begin(), dp.end())-1 << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...