|
|
вернуться в форумWA #2 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 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 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 |
|
|