fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. int[] scores = { 10, 9, 9, 8, 6, 5, 5, 5, 4, 1 };
  14. int prescore = -1;
  15. int cur = 0;
  16. int same = 0;
  17. for (int i : scores)
  18. {
  19. if (i == prescore)
  20. {
  21. System.out.println(i + " - " + cur);
  22. same++;
  23. }
  24. else
  25. {
  26. cur = cur + same;
  27. cur++;
  28. prescore = i;
  29. same = 0;
  30. System.out.println(i + " - " + cur);
  31. }
  32.  
  33. }
  34. }
  35. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
10 - 1
9 - 2
9 - 2
8 - 4
6 - 5
5 - 6
5 - 6
5 - 6
4 - 9
1 - 10