ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1581. Teamwork

WA #2
Posted by Apurv Nagar 6 Apr 2016 18:41
below is my java code:

import java.util.*;
public class timus1581
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        if (t>=1 && t<=1000)
       {
        int i = 0; int cnt = 0;
        int a[] = new int[t];
        for (i = 0; i <= t-1; i++)
        {
            a[i] = sc.nextInt();
          if (a[i]>=1 && a[i]<=10)
          {
              continue;
          }
          else
          {
              System.exit(0);
          }
        }
        for (i = 0; i < t-1; i++)
        {
            if (a[i] == a[i+1])
            {
                cnt++;
            }
            else
            {
                System.out.print((cnt+1) + " " + a[i] + " ");
                cnt = 0;
            }
            if (t == i + 2)
            {
                System.out.print((cnt+1) + " " + a[i]);
                cnt = 0;
            }
        }
      }
    }
}

Edited by author 09.04.2016 14:32
Re: WA #1
Posted by retired 6 Apr 2016 18:56
System.out.println("Enter no. of test cases");
System.out.println("Enter Integers");

How do you think a robot would distinguish those messages from your real answer.

http://acm.timus.ru/help.aspx?topic=judge
«The program must print only the data that is required by the problem statement. The program must not print any prompts (“Enter N:”). The program must not wait for pressing a key at the end of execution.»
Re: WA #2
Posted by Alexandr Vasilyev 12 Jun 2016 13:54
for (i = 0; i < t-1; i++)
        {
            if (a[i] == a[i+1])
            {
                cnt++;
            }
            else
            {
                System.out.print((cnt+1) + " " + a[i] + " ");
                cnt = 0;
            }
            if (t == i + 2)
            {
                System.out.print((cnt+1) + " " + a[i]);
                cnt = 0;
            }
        }
I am not understand this part.

Edited by author 12.06.2016 13:59