#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3146 ms |
384 KB |
Output is correct |
4 |
Execution timed out |
4080 ms |
384 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3146 ms |
384 KB |
Output is correct |
4 |
Execution timed out |
4080 ms |
384 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |