Submission #1072787

#TimeUsernameProblemLanguageResultExecution timeMemory
1072787HappyCapybaraGlobal Warming (CEOI18_glo)C++17
0 / 100
118 ms7764 KiB
#include<bits/stdc++.h> using namespace std; int n; vector<int> st; void update(int pos, int val, int node=1, int tl=0, int tr=n-1){ if (tl == tr){ st[node] = val; return; } int tm = (tl+tr)/2; if (pos <= tm) update(pos, val, node*2, tl, tm); else update(pos, val, node*2+1, tm+1, tr); st[node] = max(st[node*2], st[node*2+1]); } int query(int l, int r, int node=1, int tl=0, int tr=n-1){ if (l <= tl && tr <= r) return st[node]; int tm = (tl+tr)/2; int res = 0; if (l <= tm) res = max(res, query(l, r, node*2, tl, tm)); if (tm+1 <= r) res = max(res, query(l, r, node*2+1, tm+1, tr)); return res; } int main(){ int x; cin >> n >> x; vector<int> v(n); for (int i=0; i<n; i++) cin >> v[i]; st.resize(4*n, 0); vector<pair<int,int>> p(n); for (int i=0; i<n; i++) p[i] = {v[i], -i}; sort(p.begin(), p.end()); for (int i=n-1; i>=0; i--){ int j = -p[i].second; int bsf = query(0, j); update(j, bsf+1); } cout << st[1] << "\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...