Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
这个不能过?莫非要高精度#include <iostream> using namespace std; const int size = 5005; struct node{ int value; int layer; __int64 num; }; node a[size]; int tmpla[size]={2000000000}; int main () { int input, big; cin >> input; big = 0; for (int i = 1; i <= input; ++i) { cin >> a[i].value; int j; for (j = i-1; j >= 0; --j) { if (tmpla[j] > a[i].value ) break; } tmpla[j+1] = a[i].value; a[i].layer = j+1; if (a[i].layer>big) big = a[i].layer; a[i].num = 0; if (a[i].layer == 1) a[i].num = 1; } __int64 sum = 0; int last = 0; int lastmax = -1; for (int i = 1; i <= input; ++i) { last = -1; for (int j = i-1; j > 0; --j) { if (a[i].layer-1 == a[j].layer && a[i].value < a[j].value && a[j].value != last) { a[i].num += a[j].num; last = a[j].value; } } if (a[i].layer == big && a[i].value != lastmax ) { lastmax = a[i].value; sum += a[i].num; } } cout << big <<" "; printf ("%I64d\n", sum); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator