Task: | Kasat |
Sender: | |
Submission time: | 2015-09-11 17:51:29 +0300 |
Language: | Java |
Status: | READY |
Result: | 33 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | ACCEPTED | 33 |
#3 | WRONG ANSWER | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.32 s | 1 | details |
#2 | ACCEPTED | 0.33 s | 2 | details |
#3 | WRONG ANSWER | 0.35 s | 3 | details |
Code
import java.util.Arrays; import java.util.Scanner; public class Main { public static void ratkaise(int[] lista, int n) { Arrays.sort(lista); int ka = (lista[0] + lista[1] + lista[2])/3; int mod = (lista[0] + lista[1] + lista[2])%3; int ai = ka, bi = ka, ci = ka; if(mod > 0) ci++; if(mod > 1) bi++; if(lista[1] < bi) { int diff = lista[1] - lista[0]; if(diff <= n) { lista[0] += diff; lista[2] -= diff; n -= diff; int m = Math.min(lista[2] - ci, n); lista[0] += m/2; lista[1] += m/2 + m%2; lista[2] -= m; n -= m; } else { lista[0] += n; lista[2] -= n; n = 0; } } else if(lista[1] > bi) { int diff = lista[2] - lista[1]; if(diff <= n) { lista[0] += diff; lista[2] -= diff; n -= diff; int m = ai - lista[0]; lista[0] += Math.min(m, n); lista[1] -= Math.min(m, n)/2; lista[2] -= Math.min(m, n)/2 + Math.min(m, n)%2; n -= m; } else { lista[0] += n; lista[2] -= n; n = 0; } } else { int m = Math.min(ai - lista[0], n); lista[0] += m; lista[2] -= m; n -= m; } if(mod == 0) { if(n % 2 != 0) { lista[0]--; lista[2]++; } } Arrays.sort(lista); } public static void tulosta(int[] lista) { System.out.println(lista[0] + " "+ lista[1] + " " + lista[2]); } public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); int[][] taulukko = new int[t][3]; int[] ns = new int[t]; for (int i = 0; i < t; i++) { taulukko[i][0] = input.nextInt(); taulukko[i][1] = input.nextInt(); taulukko[i][2] = input.nextInt(); ns[i] = input.nextInt(); } for (int i = 0; i < t; i++) { ratkaise(taulukko[i], ns[i]); tulosta(taulukko[i]); } input.close(); } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
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 24 24 24 45 45 46 43 46 94 32 32 33 ... |
Test 2
Group: 2
Verdict: ACCEPTED
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 54 54 55 54 55 55 63 63 64 36 37 38 ... |
Test 3
Group: 3
Verdict: WRONG ANSWER
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 436205296 436205297 436205298 351062567 351062568 351062568 ... |