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

WA了一次才AC 贴个代码……

Posted by yyii1111 at 2011-11-22 00:24:18 on Problem 3183
在线算法……
写得略难看
#include<cstdio>
using namespace std;

int main()
{
    int n;
    scanf("%d",&n);
    bool boom = true;
    int last = -1;
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        if(boom)
        {
            if(x>=last) boom = false;
        }
        else
        {
            if(x<=last)
            {
                if(x<last) boom = true;
                printf("%d\n",i);
            }
        }
        if(i == n-1)
        {
            if(!boom)   printf("%d\n",i+1);
        }
        last = x;
    }
    return 0;
}

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