CSES - Putka Open 2015 – 3/6 - Results
 Task: Kasat Sender: Submission time: 2015-09-12 09:46:11 +0300 Language: Java Status: READY Result: 0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.31 s1details
#20.31 s2details
#30.34 s3details

### Code

```import java.math.BigInteger;
import java.util.*;

public class kasat {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

int kpl = input.nextInt();

String[] ans = new String[kpl];

long a = 0;
long b = 0;
long c = 0;
long n = 0;

long[] pussit = new long[3];

long min = 0;
long mid = 0;
long max = 0;

long ero1 = 0;
long ero2 = 0;
long apu = 0;

long sum = 0;
long ka = 0;
long osa = 0;

long max_min = 0;
long min_max = 0;
long n_viela = 0;

for (int i = 0; i < kpl; i++) {
a = input.nextLong();
b = input.nextLong();
c = input.nextLong();
n = input.nextLong();

pussit[0] = a;
pussit[1] = b;
pussit[2] = c;

Arrays.sort(pussit);

min = pussit[0];
mid = pussit[1];
max = pussit[2];

ero1 = max - mid;
ero2 = mid - min;

sum = a + b + c;
ka = sum / 3;
osa = sum % 3;
max_min = ka + osa%2;
min_max = ka;

if ((sum%3 == 0) && ((max-min)%2 != n%2)) max_min += 1;

if ((ero1 >= n) && (ero2 >= n)) {  // kaikki siirot max -> min
min = min + n;
max = max - n;
}

else if ((ero1 <= n) && (ero2 >= n)) {  // siirot max,mid -> min

min = min + n;
n_viela = n - ero1;

if (min > min_max) {
n_viela = n_viela - (min - min_max);
min = min_max;
}

max = max - ero1 - n_viela/2;
mid = mid - n_viela/2 - n_viela%2;

}

else if ((ero1 > n) && (ero2 <= n)) {  // siirot max -> mid,min

max = max - n;
n_viela = n - ero2;

if (max < max_min) {
n_viela = n_viela - (max_min - max);
max = max_min;
}
mid = mid + n_viela/2 + n_viela%2;
min = min + ero2 + n_viela/2;
}

else {  // pienet erot -> kaikki keskelle

min = ka;
mid = ka;
max = ka;

if (osa > 0) max = max + 1;
if (osa > 1) mid = mid + 1;

if (max < max_min) {
max = max_min;
min = min - 1;
}

}

ans[i] = "" + min + " " + mid + " " + max;

}

input.close();

for (int i = 0; i < kpl; i++) {
System.out.println(ans[i]);
}

}
}```

### Test details

Group: 1

Verdict:

input
1000
7 69 64 45
37 5 30 81
50 49 37 38
46 37 100 6
...

correct output
46 47 47
24 24 24
45 45 46
43 46 94
32 32 33
...

user output
46 47 47
23 24 25
45 45 46
43 46 94
32 32 33
...

#### Test 2

Group: 2

Verdict:

input
1000
19 13 88 978977859
67 57 39 960003440
81 16 67 971611942
92 96 2 957979201
...

correct output
39 40 41
54 54 55
54 55 55
63 63 64
36 37 38
...

user output
40 40 40
54 54 55
54 55 55
63 63 64
36 37 38
...

#### Test 3

Group: 3

Verdict:

input
1000
211358104 753479603 549127067 ...

correct output
504654924 504654925 504654925
589019272 589019272 589019273
101309993 101309994 101309994
436205296 436205297 436205298
351062567 351062568 351062568
...

user output
504654924 504654925 504654925
589019272 589019272 589019273
101309993 101309994 101309994
436205297 436205297 436205297
351062567 351062568 351062568
...