Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## WA的人来看看这组简单数据

Posted by temp_ptr at 2011-10-07 14:19:34 on Problem 1952
```6
4 3 4 1 3 1

======

#include <iostream>
#include <fstream>
using namespace std;
const int N = 5001;
int n, dp_len[N], a[N], ans_len, dp_time[N],ans_time;

int main()
{
fstream fin("1952.txt");
fin>>n;
for(int i = 1; i <= n; i++)
fin>>a[i];
ans_len = 1; dp_len[n] = 1; dp_time[n] = 1;
for(int i = n-1; i >= 1; i--)
{
dp_len[i] = 1; dp_time[i] = 1;
for(int j = i+1; j <= n; j++)
if(a[i] > a[j])
{
if(dp_len[j] + 1 > dp_len[i])
{
dp_len[i] = dp_len[j]+1; dp_time[i] = dp_time[j];
}
else if(dp_len[j]+1 == dp_len[i])
dp_time[i] += dp_time[j];
}
else if(a[i] == a[j])//key point!
{
if(dp_len[i] == 1)
dp_time[i] = 0;
break;
}
///////////////////////////
if(dp_len[i] > ans_len)
ans_len = dp_len[i];
}
///////////////////////////
ans_time = 0;
for(int i = 1; i <= n; i++)
if(dp_len[i] == ans_len)
ans_time += dp_time[i];
cout<<ans_len<<" "<<ans_time<<endl;
return 0;
}```

Followed by: