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 |
Re:好奇怪,明明错的代码竟然AC了!In Reply To:好奇怪,明明错的代码竟然AC了! Posted by:710822432 at 2009-07-17 21:15:48 > #include<iostream> > > using namespace std; > > int main() > { > int i, j, n, max = 1, a[1001], b[1001]; > while( cin >> n ) > { > for( i = 0; i < n; i++ ) > { > cin >> a[i]; > } > > b[0] = 1; > for( i = 1; i < n; i++ ) > { > b[i] = 1; > for( j = 0; j < i; j++ ) > { > if( a[j] < a[i] && b[j] + 1 > b[i] ) b[i] = b[j] + 1; > } > if( b[i] > max )max = b[i]; > } > cout << max << endl; > } > return 0; > } > > 很明显,max位置放错了,提交了好几遍AC都了,难道测试数据是递增的吗? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator