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

一次AC,贴上精炼代码

Posted by lzh901126 at 2013-06-19 00:37:51 on Problem 1068
#include <iostream>
using namespace std;
short a[20];
int main(void)
{
  short n,m,i,j,rightCount,tmp1,tmp2=0;
    cin>>n;
    while(n--)
    { 
       cin>>m;
       tmp2=0;
       for(i=0;i<m;i++){
         cin>>tmp1;
         a[i] = tmp1 - tmp2;
         tmp2 = tmp1; 
         rightCount = 1;           
         for(j=i;j>=0;j--){
           if(a[j]>0){
              a[j]--;
              break;
              }
            else
              rightCount++;
              }
         cout<<rightCount<<" ";
         }
       cout<<endl;
    }
    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