1 条题解
-
-1njnu19170318 (19170318) LV 8 @ 2019-01-22 19:59:32
#include <iostream>
using namespace std;struct T
{
int DJ;
int DP;
}arr[100010];void Qsort(int l, int r)
{
int i = l;
int j = r;
int mid = arr[(l + r) / 2].DJ;
while (i < j)
{
while (i < r && arr[i].DJ < mid) ++i;
while (l < j && arr[j].DJ > mid) --j;
if (i <= j)
{
struct T temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
++i; --j;
}
}
if (i < r) Qsort(i, r);
if (l < j) Qsort(l, j);
}int main()
{
int n, i, j;
cin >> n;
for (i = 0; i < n; ++i)
cin >> arr[i].DJ >> arr[i].DP;Qsort(0, n - 1);
int c[100010] = {0};
c[0] = 1;
for (i = 1; i < n; ++i)
for (j = i - 1; j >= 0; --j)
if (arr[i].DP > arr[j].DP && (c[j] + 1) > c[i])
c[i] = c[j] + 1;
int max = 0;
for (i = 0; i < n; ++i)
if (c[i] > max)
max = c[i];
cout << max << endl;
return 0;
}
- 1
信息
- 难度
- 5
- 分类
- (无)
- 标签
- (无)
- 递交数
- 20
- 已通过
- 12
- 通过率
- 60%
- 被复制
- 3
- 上传者