|
|
back to boardWA10 Hi i'm getting WA for #10, can anyone help with this? My code works for everything ive tested so far public static void main( String [] args){ int a,b; Scanner sc = new Scanner(System.in); a = sc.nextInt(); b = sc.nextInt(); int[] array = new int[b]; for( int i = 0; i < b; i++) array[i] = sc.nextInt(); int carry = 0; for( int i = 0; i < b; i++){ array[i] = array[i] + carry; if(array[i] > a) carry = array[i]%a; else carry = 0; array[i] = array[i] - carry; } int answer=0; array[b-1]+=carry; int current = 0; for( int i = 0; i < b; i++){ if(array[current] <= a){ array[current] = 0; current++; } else array[current] = array[current] - a; } for( int i = 0; i < b; i++) answer+=array[i]; System.out.println(answer);
} Edited by author 05.08.2013 14:55 Edited by author 05.08.2013 17:31 |
|
|