Monday, November 14, 2016

1241 - Pinocchio

Problem Link : http://lightoj.com/volume_showproblem.php?problem=1241

Solution :

#include<bits/stdc++.h>
using namespace std;


int main()
{

    int t;
    scanf("%d",&t);

    int n,a,cnt,b,c;

    for(int ca=1; ca<=t; ca++)
    {
        cnt=0;
        a=-1;
        b=2;
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a);
            c=a-b;

            cnt=cnt+(c/5);
            if((c%5)!=0) cnt++;

            b=a;

        }
        printf("Case %d: %d\n",ca,cnt);
    }


}

No comments:

Post a Comment