Submission #3043932
Source Code Expand
import static java.lang.Math.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskX solver = new TaskX(); solver.solve(1, in, out); out.close(); } static int INF = 1 << 30; static long LINF = 1L << 55; static int MOD = 1000000007; static int[] mh4 = { 0, -1, 1, 0 }; static int[] mw4 = { -1, 0, 0, 1 }; static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 }; static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 }; static class TaskX { public void solve(int testNumber, InputReader in, PrintWriter out) { int R = in.nextInt(), G = in.nextInt(), B = in.nextInt(); int p = 1000; char[] s = new char[2000]; Arrays.fill(s, 'x'); int l = 0+p; int r = 0+p; while (G > 0) { if (s[l] == 'x') { s[l] = 'G'; G--; } l--; if (G <= 0) break; if (s[r] == 'x') { s[r] = 'G'; G--; } ++r; } l = -100+p; r = -100+p; while (R > 0) { if (s[l] == 'x') { s[l] = 'R'; R--; } l--; if (R <= 0) break; if (s[r] == 'G') continue; if (s[r] == 'x') { s[r] = 'R'; R--; } ++r; } l = 100+p; r = 100+p; while (B > 0) { if (s[r] == 'x') { s[r] = 'B'; B--; } ++r; if (B <= 0) break; if (s[l] == 'G') continue; if (s[l] == 'x') { s[l] = 'B'; B--; } l--; } long ans = 0; int gr = -100 + p; int gg = 0 + p; int gb = 100 + p; int Rl = INF, Rr = -INF, Gl = INF, Gr = -INF, Bl = INF, Br = -INF; for (int i = 0; i < s.length; i++) { if (s[i] == 'R') { Rl = min(Rl, i); Rr = max(Rr, i); } if (s[i] == 'G') { Gl = min(Gl, i); Gr = max(Gr, i); } if (s[i] == 'B') { Bl = min(Bl, i); Br = max(Br, i); } } // out.printf("%d %d %d %d %d %d \n", Rl-gr, Rr-gr, Gl-gg, Gr-gg, Bl-gb, Br-gb); // if (Rr >= gr) { // ans += abs(Rl - gr) * (abs(Rl - gr)+1) / 2; // ans += abs(Rr - gr) * (abs(Rr - gr)+1) / 2; // } else { // ans += abs(Rl - gr) * (abs(Rl - gr)+1) / 2; // ans -= abs(Rr - gr) * (abs(Rr - gr)+1) / 2; // } // // ans += abs(Gl - gg) * (abs(Gl - gg)+1) / 2; // ans += abs(Gr - gg) * (abs(Gr - gg)+1) / 2; // // if (Bl <= gb) { // ans += abs(Bl - gb) * (abs(Bl - gb)+1) / 2; // ans += abs(Br - gb) * (abs(Br - gb)+1) / 2; // } else { // ans -= abs(Bl - gb) * (abs(Bl - gb)+1) / 2; // ans += abs(Br - gb) * (abs(Br - gb)+1) / 2; // } for (int i = 0; i < s.length; i++) { if (s[i] == 'R') { ans += abs(i - gr); } if (s[i] == 'G') { ans += abs(i - gg); } if (s[i] == 'B') { ans += abs(i - gb); } } StringBuilder sb = new StringBuilder(); for (char c : s) { if (c != 'x') sb.append(c); } // out.println(sb.toString()); out.println(ans); } } static class InputReader { BufferedReader in; StringTokenizer tok; public String nextString() { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine(), " "); } catch (IOException e) { throw new InputMismatchException(); } } return tok.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public double nextDouble() { return Double.parseDouble(nextString()); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[] nextIntArrayDec(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt() - 1; } return res; } public long[] nextLongArray(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public long[] nextLongArrayDec(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong() - 1; } return res; } public InputReader(InputStream inputStream) { in = new BufferedReader(new InputStreamReader(inputStream)); tok = new StringTokenizer(""); } } }
Submission Info
Submission Time | |
---|---|
Task | D - マーブル |
User | tutuz |
Language | Java8 (OpenJDK 1.8.0) |
Score | 40 |
Code Size | 4838 Byte |
Status | WA |
Exec Time | 73 ms |
Memory | 23380 KB |
Judge Result
Set Name | sub1 | sub2 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 10 / 10 | 30 / 30 | 0 / 60 | ||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
sub1 | sample_01_ABC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt |
sub2 | sample_01_ABC.txt, sample_02_BC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt |
All | sample_01_ABC.txt, sample_02_BC.txt, sample_03_C.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt, test_C_56.txt, test_C_57.txt, test_C_58.txt, test_C_59.txt, test_C_60.txt, test_C_61.txt, test_C_62.txt, test_C_63.txt, test_C_64.txt, test_C_65.txt, test_C_66.txt, test_C_67.txt, test_C_68.txt, test_C_69.txt, test_C_70.txt, test_C_71.txt, test_C_72.txt, test_C_73.txt, test_C_74.txt, test_C_75.txt, test_C_76.txt, test_C_77.txt, test_C_78.txt, test_C_79.txt, test_C_80.txt, test_C_81.txt, test_C_82.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01_ABC.txt | AC | 71 ms | 18516 KB |
sample_02_BC.txt | AC | 70 ms | 19028 KB |
sample_03_C.txt | WA | 70 ms | 19924 KB |
test_ABC_01.txt | AC | 71 ms | 19156 KB |
test_ABC_02.txt | AC | 70 ms | 19284 KB |
test_ABC_03.txt | AC | 71 ms | 20820 KB |
test_ABC_04.txt | AC | 70 ms | 18004 KB |
test_ABC_05.txt | AC | 70 ms | 18772 KB |
test_ABC_06.txt | AC | 70 ms | 18900 KB |
test_ABC_07.txt | AC | 70 ms | 18260 KB |
test_ABC_08.txt | AC | 70 ms | 23380 KB |
test_ABC_09.txt | AC | 70 ms | 21460 KB |
test_ABC_10.txt | AC | 70 ms | 21332 KB |
test_ABC_11.txt | AC | 70 ms | 18900 KB |
test_ABC_12.txt | AC | 71 ms | 20564 KB |
test_ABC_13.txt | AC | 69 ms | 17748 KB |
test_ABC_14.txt | AC | 69 ms | 19156 KB |
test_ABC_15.txt | AC | 70 ms | 20564 KB |
test_ABC_16.txt | AC | 70 ms | 19156 KB |
test_ABC_17.txt | AC | 70 ms | 19028 KB |
test_ABC_18.txt | AC | 69 ms | 18132 KB |
test_ABC_19.txt | AC | 69 ms | 20692 KB |
test_ABC_20.txt | AC | 70 ms | 21204 KB |
test_ABC_21.txt | AC | 70 ms | 19924 KB |
test_ABC_22.txt | AC | 68 ms | 17876 KB |
test_ABC_23.txt | AC | 69 ms | 21460 KB |
test_ABC_24.txt | AC | 70 ms | 21076 KB |
test_ABC_25.txt | AC | 71 ms | 18772 KB |
test_ABC_26.txt | AC | 70 ms | 20692 KB |
test_ABC_27.txt | AC | 70 ms | 16084 KB |
test_ABC_28.txt | AC | 70 ms | 18516 KB |
test_BC_29.txt | AC | 70 ms | 20180 KB |
test_BC_30.txt | AC | 70 ms | 18772 KB |
test_BC_31.txt | AC | 69 ms | 21332 KB |
test_BC_32.txt | AC | 70 ms | 21460 KB |
test_BC_33.txt | AC | 69 ms | 19412 KB |
test_BC_34.txt | AC | 69 ms | 19540 KB |
test_BC_35.txt | AC | 70 ms | 16468 KB |
test_BC_36.txt | AC | 69 ms | 18388 KB |
test_BC_37.txt | AC | 70 ms | 19412 KB |
test_BC_38.txt | AC | 69 ms | 19540 KB |
test_BC_39.txt | AC | 70 ms | 22868 KB |
test_BC_40.txt | AC | 70 ms | 19924 KB |
test_BC_41.txt | AC | 69 ms | 17876 KB |
test_BC_42.txt | AC | 69 ms | 20692 KB |
test_BC_43.txt | AC | 70 ms | 18388 KB |
test_BC_44.txt | AC | 70 ms | 21460 KB |
test_BC_45.txt | AC | 70 ms | 18644 KB |
test_BC_46.txt | AC | 71 ms | 20820 KB |
test_BC_47.txt | AC | 70 ms | 18900 KB |
test_BC_48.txt | AC | 70 ms | 21460 KB |
test_BC_49.txt | AC | 69 ms | 17876 KB |
test_BC_50.txt | AC | 69 ms | 19156 KB |
test_BC_51.txt | AC | 69 ms | 18132 KB |
test_BC_52.txt | AC | 71 ms | 19156 KB |
test_BC_53.txt | AC | 69 ms | 19028 KB |
test_BC_54.txt | AC | 70 ms | 18900 KB |
test_BC_55.txt | AC | 70 ms | 23380 KB |
test_C_56.txt | WA | 70 ms | 19540 KB |
test_C_57.txt | WA | 70 ms | 21460 KB |
test_C_58.txt | WA | 71 ms | 19284 KB |
test_C_59.txt | WA | 69 ms | 18516 KB |
test_C_60.txt | WA | 69 ms | 18132 KB |
test_C_61.txt | WA | 70 ms | 17876 KB |
test_C_62.txt | WA | 70 ms | 18772 KB |
test_C_63.txt | WA | 70 ms | 21460 KB |
test_C_64.txt | WA | 70 ms | 21204 KB |
test_C_65.txt | WA | 70 ms | 20820 KB |
test_C_66.txt | WA | 71 ms | 22740 KB |
test_C_67.txt | WA | 70 ms | 19540 KB |
test_C_68.txt | AC | 70 ms | 17616 KB |
test_C_69.txt | WA | 70 ms | 18004 KB |
test_C_70.txt | WA | 71 ms | 19284 KB |
test_C_71.txt | WA | 70 ms | 19540 KB |
test_C_72.txt | WA | 70 ms | 19924 KB |
test_C_73.txt | WA | 71 ms | 21460 KB |
test_C_74.txt | WA | 70 ms | 17748 KB |
test_C_75.txt | WA | 70 ms | 18644 KB |
test_C_76.txt | WA | 70 ms | 21460 KB |
test_C_77.txt | AC | 72 ms | 20436 KB |
test_C_78.txt | WA | 70 ms | 19412 KB |
test_C_79.txt | WA | 71 ms | 20180 KB |
test_C_80.txt | AC | 69 ms | 21332 KB |
test_C_81.txt | WA | 73 ms | 17748 KB |
test_C_82.txt | AC | 71 ms | 19540 KB |