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

0s水过

Posted by hymscott at 2016-08-23 21:24:56 on Problem 1068
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int maxn=25;

int a[maxn],mius[maxn],res[maxn];

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        memset(a,0,sizeof(a));
        memset(mius,0,sizeof(mius));
        memset(res,0,sizeof(res));
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
            if(i==0){
                mius[i]=a[i];
            }
            else{
                mius[i]=a[i]-a[i-1];
            }
        }
        for(int i=0;i<n;i++){
            if(!a[i]){
                res[i]=0;
            }
            else{
                res[i]=1;
                for(int j=i;j>=0;j--){
                    if(mius[j]){
                        mius[j]--;
                        break;
                    }
                    else{
                        res[i]++;
                    }
                }
            }
        }
        for(int i=0;i<n;i++){
            printf("%d ",res[i]);
        }
        printf("\n");
    }
    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