이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |