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

Re:好奇怪,明明错的代码竟然AC了!

Posted by zzw890827 at 2009-11-02 21:23:34 on Problem 2533
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator