记录编号 316367 评测结果 AAAAAAAAAA
题目名称 越低越买 最终得分 100
用户昵称 Gravatar安呐一条小咸鱼。 是否通过 通过
代码语言 C++ 运行时间 0.144 s
提交时间 2016-10-06 17:40:15 内存使用 10.00 MiB
显示代码纯文本
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stack>
#include <iostream>
#include <cstdlib>
#include <cmath>
#define me(a,b) memset(a,b,sizeof(a))
#define rep(a,l,r) for(int a=l;a<=r;a++)
#define maxn 5050
#define N 500 
using namespace std;
class CBigInt{
	private :
		int m_num[N],len;
	public :
		CBigInt(){me(m_num,0);len=1;}CBigInt(const char *ch){me(m_num,0);len=strlen(ch);for(int i=0;i<len;i++){m_num[len-i-1]=ch[i]-'0';}
		if(ch[0]=='-')--len,m_num[len-1]=-m_num[len-1];}CBigInt(const string s){me(m_num,0);len=s.length();for(int i=0;i<len;i++)
		{m_num[ i ]=s[i]-'0';}}CBigInt operator +(const CBigInt& x)const{CBigInt ret;int l=max(len,x.len);
		ret.len=l;for(int i=0;i<l;++i){ret.m_num[i]+=m_num[i]+x.m_num[i];if(ret.m_num[i]>=10){ret.m_num[i+1]=1;ret.m_num[i]-=10;}}
		if(ret.m_num[l]!=0)ret.len=l+1;return ret;}CBigInt operator -(const CBigInt& x)const{CBigInt ret;int id,d=0;
		for(id=0;id<len;id++){d=m_num[id]+d;if(d>=x.m_num[id]){ret.m_num[id]=d-x.m_num[id];d=0;}else{ret.m_num[id]=d+10-x.m_num[id];d=-1;}}
		id=len-1;while(id>0&&ret.m_num[id]==0)id--;ret.len=id+1;return ret;}CBigInt operator *(const CBigInt& x)const{CBigInt ret;
		int i,j;ret.len=len+x.len-1;for(i=0;i<len;++i){for(j=0;j<x.len;++j){ret.m_num[i+j]+=m_num[i]*x.m_num[j];if(ret.m_num[i+j]>=10)
		{ret.m_num[i+j+1]+=ret.m_num[i+j]/10;ret.m_num[i+j]%=10;}}}if(ret.m_num[ret.len]!=0)ret.len+=1;return ret;}
		void print(){for(int i=len-1;i>=0;--i)printf("%d",m_num[i]);printf("\n");}
};
int  n , f[maxn] , a[maxn] ;
CBigInt g[maxn] ;
int main()
{
	freopen("buylow.in","r",stdin);
	freopen("buylow.out","w",stdout);
	me(f,0) ;
	scanf( "%d" , &n );
	rep( i , 1 , n )scanf( "%d" , &a[i] );
	rep( i , 1 , n )f[i] = 1 ;
	rep( i , 1 , n )
	{
		rep( j , 1 , i-1 )
		{
			if( a[i] < a[j] )f[i] = max ( f[i] , f[j] + 1 );
		}
		if( f[i] == 1 )g[i] = ("1");
	}
	rep( i , 1 , n )
	{
		rep( j , 1 , i-1 )
		{
			if( f[i] == f[j] + 1 && a[i] < a[j] ) g[i] = g[i] + g[j] ;		
			if( f[i] == f[j] && a[i] == a[j] )g[i] = g[i] - g[j]; 
		}
	}
	int ans1 = 0 ;
	CBigInt ans2 ("0") ;
	rep( i , 1 , n )
	{
		if( ans1 < f[i] )
		{
			ans1 = f[i];
			ans2 = g[i];
		}
		else if ( ans1 == f[i] )ans2 = ans2 + g[i];
	}
	printf("%d ", ans1 );
	ans2.print();
}