Блог пользователя SD_1_2

Автор SD_1_2, история, 3 года назад, По-английски

Given an array , take 2 elements of a[i] and a[j] and take difference of a[i]-a[j] or a[j]-a[i] for i!=j and delete both elements and place the difference back into array and keep taking difference until we have one element in array with maximum possible value.

Arrays can contain negative and positive values.

input form : space separated integers of an array ouput : max value of differences until one element

INPUT 1: -5 3 -4 -2 -2 OP : 16

INPUT 2: 3 -3 2 -6 2 -1 OP:17

INPUT 3: 1 OP:1

INPUT4: -2 -4 -6 -8 OP: ?

INPUT 5: 2 4 6 8 10 OP:6

Полный текст и комментарии »

  • Проголосовать: нравится
  • -46
  • Проголосовать: не нравится

Автор SD_1_2, история, 3 года назад, По-английски

Two Arrays A and B of length N , where N is even . There are two players kevin and paul. Total turns = N / 2 for each turn , Kevin picks two different unused index i and j paul picks either i or j , whichever value at index(i or j) of array B is maximum , if paul picks index i of Array B , then kevin picks j of Array A else if paul picks index j of Array B, then kevin picks i of Array A calculate sum of score of paul and sum of score of kevin for each turn find the maximum difference of their scores.

N-> Array size n sepated integers // Array A n separated integers // Array B

Ex input : N=2 1 1 1 1 Op: 0

N=4 4 2 8 6 6 5 7 8 Op : 4

N=6 7 8 2 6 10 3 9 1 3 10 2 4 Op: 8

Полный текст и комментарии »

  • Проголосовать: нравится
  • -34
  • Проголосовать: не нравится