fork(1) download
  1. import java.util.Scanner;
  2. class Ideone {
  3.  
  4. public static void main(String args[]) {
  5. Scanner in = new Scanner(System.in);
  6. int S = in.nextInt();
  7. int[] array = {90,30,100,40,20};
  8. int len = array.length;
  9. int sAvg = S/len;
  10.  
  11. int trackSmallerThanAverage = 0;
  12. int countMorethanAverage = 0;
  13.  
  14. for(int i=0; i<len; i++) {
  15. if(array[i] > sAvg) {
  16. countMorethanAverage ++;
  17. } else if (array[i]<sAvg) {
  18. trackSmallerThanAverage += array[i];
  19. }
  20.  
  21. }
  22.  
  23. int finalValue = ( S - trackSmallerThanAverage )/countMorethanAverage;
  24. System.out.println(finalValue);
  25. in.close();
  26.  
  27. }
  28. }
  29.  
Success #stdin #stdout 0.11s 380672KB
stdin
210
stdout
60