-
Notifications
You must be signed in to change notification settings - Fork 1
/
P1233.c
36 lines (30 loc) · 804 Bytes
/
P1233.c
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
#include <stdio.h>
#include <stdlib.h>
#define MAXN 5000
struct Stick {
int l, w;
} st[MAXN];
int cmp(const void *a, const void *b) {
struct Stick *st_a = (struct Stick *)a;
struct Stick *st_b = (struct Stick *)b;
return st_a->l != st_b->l ? st_b->l - st_a->l : st_b->w - st_a->w;
}
int dp[MAXN];
int max(int a, int b) { return a > b ? a : b; }
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &st[i].l, &st[i].w);
}
qsort(st, n, sizeof(struct Stick), cmp);
int ans = 0;
for (int i = 0; i < n; i++) {
dp[i] = 1; //Init
for (int j = 0; j < i; j++)
if (st[j].w < st[i].w)
dp[i] = max(dp[i], dp[j] + 1);
ans = max(ans, dp[i]);
}
printf("%d\n", ans);
}