-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10131.cpp
More file actions
77 lines (71 loc) · 873 Bytes
/
10131.cpp
File metadata and controls
77 lines (71 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<stdio.h>
#include<algorithm>
using namespace std;
long n,dp[1010],dir[1010];
struct ss
{
long w,iq,no;
}T[1010];
bool cmp(ss aa,ss bb)
{
if(aa.iq==bb.iq)
return aa.w<bb.w;
return aa.iq>bb.iq;
}
long longest(long u)
{
if(u==n)
return 0;
if(dp[u]!=-1)
return dp[u];
long v,mx=0,p;
for(v=u+1;v<n;v++)
{
if(T[v].w>T[u].w)
{
p=longest(v);
if(mx<p)
{
dir[u]=v;
mx=p;
}
}
}
dp[u]=mx+1;
return dp[u];
}
void path_print(long start)
{
while(1)
{
printf("%ld\n",T[start].no);
if(dir[start]==-1)
break;
start=dir[start];
}
}
int main()
{
long i,mx=0,p,start;
i=0;
while(~scanf("%ld%ld",&T[i].w,&T[i].iq))
{
dir[i]=dp[i]=-1;
T[i].no=i+1;
i++;
}
n=i+1;
sort(T,T+i,cmp);
for(i=0;i<n;i++)
{
p=longest(i);
if(mx<p)
{
start=i;
mx=p;
}
}
printf("%ld\n",mx);
path_print(start);
return 0;
}