96822024-02-25 11:41:51zeytonxHadjáratcpp17Time limit exceeded 0/100298ms15136 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef set<ll> sll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef vector<vll> v2ll;
typedef map<ll,ll> mll;
typedef vector<pll> vpll;
typedef map<pll,ll> mpll;
typedef vector<vpll> v2pll;
typedef vector<sll> v2sll;
#define fs first
#define sc second
#define pb push_back

const ll MOD = 1e9+7;

void solve()
{
    ll n;
    cin >> n;
    vll R(n), A(n);
    for(ll i = 0; i < n; i++)
        cin >> R[i] >> A[i];
    vll dp(n, 1);
    vll parent(n);
    for(ll i = 0; i < n; i++)
        parent[i] = i;
    ll last = 0, last_v = 0;
    for(ll i = 0; i < n; i++)
    {
        for(ll j = i; j >= 0; j--)
            if(R[j] < R[i] && A[j] < A[i])
            {
                if(dp[j]+1 > dp[i])
                {
                    dp[i] = dp[j]+1;
                    parent[i] = j;
                }
            }
        if(i != 0 && dp[i-1] > dp[i])
        {
            dp[i] = dp[i-1];
            parent[i] = parent[i-1];
        }
        if(last_v < dp[i])
        {
            last = i;
            last_v = dp[i];
        }
    }

    cout << dp[n-1] << "\n";
    ll index = parent[n-1];
    vll ans;
    ans.pb(last);
    while(parent[index] != index)
    {
        ans.pb(index);
        index = parent[index];
    }
    ans.pb(index);
    reverse(ans.begin(), ans.end());
    for(ll i : ans)
        cout << i+1 << " ";
    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--)
        solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Accepted0/03ms2080 KiB
2Time limit exceeded0/0298ms3652 KiB
3Wrong answer0/43ms2976 KiB
4Wrong answer0/43ms3180 KiB
5Wrong answer0/43ms3392 KiB
6Wrong answer0/43ms3604 KiB
7Wrong answer0/43ms3692 KiB
8Wrong answer0/43ms3704 KiB
9Wrong answer0/43ms3844 KiB
10Wrong answer0/46ms3972 KiB
11Wrong answer0/479ms4408 KiB
12Time limit exceeded0/4264ms3616 KiB
13Time limit exceeded0/6266ms3820 KiB
14Time limit exceeded0/6241ms4556 KiB
15Time limit exceeded0/6264ms5068 KiB
16Time limit exceeded0/6264ms6324 KiB
17Time limit exceeded0/6261ms7600 KiB
18Time limit exceeded0/6264ms8756 KiB
19Time limit exceeded0/6273ms10240 KiB
20Time limit exceeded0/6252ms12248 KiB
21Time limit exceeded0/6250ms13808 KiB
22Time limit exceeded0/6266ms15136 KiB