CSES - Putka Open 2015 – 3/6 - Results
 Task: Kasat Sender: Submission time: 2015-09-12 22:50:51 +0300 Language: C++ Status: READY Result: 0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#20.06 s2details
#30.05 s3details

### Code

```#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char** argv) {
int t;
long a, b, c, n;
cin >> t;
vector<vector<long> > v;
for (int i = 0; i < t; ++i){
vector<long> vv;
cin >> a >> b >> c >> n;
long kasat[3] = {a, b, c};
sort(kasat, kasat+3);
long x = n > (kasat[1] - kasat[0]) ? (kasat[1] - kasat[0]) : n;
kasat[0] += x;
kasat[2] -= x;
n -= x;
if (n > 0){
if (n >= 2*(kasat[2] - kasat[0])/3) {
x = (kasat[2] - kasat[0]);
kasat[0] += x/3;
kasat[1] = kasat[0] + (x%3)/2;
kasat[2] = kasat[0] + x%3 - (x%3)/2;
if (kasat[0] == kasat[1] && kasat[0] == kasat[2]) {
n -= 2*(kasat[2] - kasat[0])/3;
kasat[0] -= n%2; kasat[2] += n%2;
}
} else {
kasat[0] += n/2;
kasat[1] += n/2 + n%2;
kasat[2] -= n;
}
}
for (int j = 0; j < 3; ++j) vv.push_back(kasat[j]);
v.push_back(vv);
}
for (int i = 0; i < t; ++i){
cout << v.at(i).at(0) << " " << v.at(i).at(1) << " " << v.at(i).at(2) << "\n";
}
return 0;
}

```

### 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
52 64 24
24 24 24
46 45 45
43 46 94
33 32 32
...

#### 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
39 40 41
55 54 54
55 55 54
64 63 63
37 37 37
...

#### 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
504654925 504654925 504654924
589019273 589019272 589019272
101309994 101309994 101309993
436205296 436205297 436205298
351062568 351062568 351062567
...