initial
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/.metadata/
|
||||
6
CCC_2019/.classpath
Normal file
6
CCC_2019/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
CCC_2019/.gitignore
vendored
Normal file
1
CCC_2019/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
CCC_2019/.project
Normal file
17
CCC_2019/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CCC_2019</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
CCC_2019/.settings/org.eclipse.jdt.core.prefs
Normal file
11
CCC_2019/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
43
CCC_2019/src/Main.java
Normal file
43
CCC_2019/src/Main.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
public class Main {
|
||||
public static int[] top = new int[] {1, 2};
|
||||
public static int[] bottom = new int[] {3, 4};
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
String input = in.nextLine();
|
||||
String[] inputArr = input.split("");
|
||||
for(int i =0; i<inputArr.length; i++) {
|
||||
if(inputArr[i].equals("V")) {
|
||||
vFlip();
|
||||
}
|
||||
if(inputArr[i].equals("H")) {
|
||||
hFlip();
|
||||
}
|
||||
}
|
||||
print();
|
||||
}
|
||||
|
||||
public static void hFlip() {
|
||||
int temp1 = top[0];
|
||||
int temp2 = top[1];
|
||||
top[0] = bottom[0];
|
||||
top[1] = bottom[1];
|
||||
bottom[0] = temp1;
|
||||
bottom[1] = temp2;
|
||||
}
|
||||
|
||||
public static void vFlip() {
|
||||
int temp1 = top[0];
|
||||
int temp2 = bottom[0];
|
||||
top[0] = top[1];
|
||||
bottom[0] = bottom[1];
|
||||
top[1] = temp1;
|
||||
bottom[1] = temp2;
|
||||
}
|
||||
|
||||
public static void print() {
|
||||
System.out.println(top[0] + " " + top[1]);
|
||||
System.out.println(bottom[0] + " " + bottom[1]);
|
||||
}
|
||||
}
|
||||
23
CCC_2019/src/Q1.java
Normal file
23
CCC_2019/src/Q1.java
Normal file
@@ -0,0 +1,23 @@
|
||||
import java.util.Scanner;
|
||||
public class Q1 {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int a1 = in.nextInt();
|
||||
int a2 = in.nextInt();
|
||||
int a3 = in.nextInt();
|
||||
int appleScore = a1*3 + a2*2 + a3*1;
|
||||
int b1 = in.nextInt();
|
||||
int b2 = in.nextInt();
|
||||
int b3 = in.nextInt();
|
||||
int bananaScore = b1*3 + b2*2 + b3*1;
|
||||
|
||||
if(appleScore > bananaScore) {
|
||||
System.out.println("A");
|
||||
}else if(bananaScore > appleScore) {
|
||||
System.out.println("B");
|
||||
}else {
|
||||
System.out.println("T");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
16
CCC_2019/src/Q2.java
Normal file
16
CCC_2019/src/Q2.java
Normal file
@@ -0,0 +1,16 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q2 {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int numInputs = Integer.parseInt(in.nextLine());
|
||||
|
||||
for(int i =0; i<numInputs; i++) {
|
||||
String temp = in.nextLine();
|
||||
int numTimes = Integer.parseInt(temp.substring(0, temp.indexOf(" ")));
|
||||
for(int j = 0; j<numTimes; j++) {
|
||||
System.out.print(temp.substring(temp.indexOf(" ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
CCC_2019/src/Q3.java
Normal file
41
CCC_2019/src/Q3.java
Normal file
@@ -0,0 +1,41 @@
|
||||
import java.util.Scanner;
|
||||
public class Q3 {
|
||||
public static String ret = "";
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int numInputs = Integer.parseInt(in.nextLine());
|
||||
|
||||
for(int i = 0; i<numInputs; i++) {
|
||||
String temp = in.nextLine();
|
||||
while(!temp.equals("")) {
|
||||
temp = remove(temp);
|
||||
}
|
||||
System.out.println(ret);
|
||||
ret = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String remove(String temp) {
|
||||
int lastIndex = getLastIndex(temp);
|
||||
String firstPart = temp.substring(0, lastIndex + 1);
|
||||
|
||||
ret += firstPart.length() + " " + temp.substring(0, 1) + " ";
|
||||
return temp.substring(firstPart.length());
|
||||
}
|
||||
public static int getLastIndex(String str) {
|
||||
String target = str.substring(0, 1);
|
||||
|
||||
for(int i = 0; i<str.length(); i++) {
|
||||
if(str.substring(i, i+1).equals(target)) {
|
||||
|
||||
}else if(str.length() == i) {
|
||||
return str.length() - 1;
|
||||
}
|
||||
else {
|
||||
return i - 1;
|
||||
}
|
||||
}
|
||||
return str.length() - 1;
|
||||
}
|
||||
}
|
||||
43
CCC_2019/src/Q4.java
Normal file
43
CCC_2019/src/Q4.java
Normal file
@@ -0,0 +1,43 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q4 {
|
||||
public static int[] top = new int[] {1, 2};
|
||||
public static int[] bottom = new int[] {3, 4};
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
String input = in.nextLine();
|
||||
String[] inputArr = input.split("");
|
||||
for(int i =0; i<inputArr.length; i++) {
|
||||
if(inputArr[i].equals("V")) {
|
||||
vFlip();
|
||||
}
|
||||
if(inputArr[i].equals("H")) {
|
||||
hFlip();
|
||||
}
|
||||
}
|
||||
print();
|
||||
}
|
||||
|
||||
public static void hFlip() {
|
||||
int temp1 = top[0];
|
||||
int temp2 = top[1];
|
||||
top[0] = bottom[0];
|
||||
top[1] = bottom[1];
|
||||
bottom[0] = temp1;
|
||||
bottom[1] = temp2;
|
||||
}
|
||||
|
||||
public static void vFlip() {
|
||||
int temp1 = top[0];
|
||||
int temp2 = bottom[0];
|
||||
top[0] = top[1];
|
||||
bottom[0] = bottom[1];
|
||||
top[1] = temp1;
|
||||
bottom[1] = temp2;
|
||||
}
|
||||
|
||||
public static void print() {
|
||||
System.out.println(top[0] + " " + top[1]);
|
||||
System.out.println(bottom[0] + " " + bottom[1]);
|
||||
}
|
||||
}
|
||||
54
CCC_2019/src/Q5.java
Normal file
54
CCC_2019/src/Q5.java
Normal file
@@ -0,0 +1,54 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q5 {
|
||||
public static int ruleNum = 0;
|
||||
public static String ret;
|
||||
public static ArrayList<String> rules = new ArrayList<String>();
|
||||
public static ArrayList<String> rules2 = new ArrayList<String>();
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int s = 0;
|
||||
String initial = "", finish = "";
|
||||
String temp = "";
|
||||
boolean isFinished = false;
|
||||
|
||||
while(!isFinished) {
|
||||
temp = in.nextLine();
|
||||
try {
|
||||
s = Integer.parseInt(temp.substring(0, temp.indexOf(" ")));
|
||||
initial = temp.substring(temp.indexOf(" ") + 1, temp.indexOf(" ", temp.indexOf(" ")+1));
|
||||
finish = temp.substring(temp.indexOf(" ", temp.indexOf(" ") + 1) + 1);
|
||||
isFinished = true;
|
||||
}catch(Exception e){
|
||||
rules.add(temp.substring(0, temp.indexOf(" ")));
|
||||
rules2.add(temp.substring(temp.indexOf(" ") +1));
|
||||
}
|
||||
|
||||
}
|
||||
ret = initial;
|
||||
|
||||
completeNext();
|
||||
for(int i = 0; i<initial.length(); i++) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
System.out.println(s);
|
||||
System.out.println(initial);
|
||||
System.out.println(finish);
|
||||
System.out.println(rules);
|
||||
System.out.println(rules2);
|
||||
System.out.println(ret);
|
||||
|
||||
}
|
||||
|
||||
public static int completeNext() {
|
||||
for(int j = 0; j<rules.size(); j++) {
|
||||
if(ret.contains(rules.get(j))) {
|
||||
ret = ret.substring(0, ret.indexOf(rules.get(j))) + ret.substring(ret.indexOf(rules.get(j)) + rules.get(j).length());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
6
ECOO_2012/.classpath
Normal file
6
ECOO_2012/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
ECOO_2012/.gitignore
vendored
Normal file
1
ECOO_2012/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
ECOO_2012/.project
Normal file
17
ECOO_2012/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ECOO_2012</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
ECOO_2012/.settings/org.eclipse.jdt.core.prefs
Normal file
11
ECOO_2012/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
104
ECOO_2012/src/Q2.java
Normal file
104
ECOO_2012/src/Q2.java
Normal file
@@ -0,0 +1,104 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class Q2 {
|
||||
private static Q2 o = new Q2();
|
||||
|
||||
public static class Reader {
|
||||
|
||||
private BufferedReader in;
|
||||
private StringTokenizer st;
|
||||
|
||||
public Reader(InputStream inputStream) {
|
||||
in = new BufferedReader(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
public Reader(String fileName) throws FileNotFoundException {
|
||||
in = new BufferedReader(new FileReader(fileName));
|
||||
}
|
||||
|
||||
public String next() throws IOException {
|
||||
while (st == null || !st.hasMoreTokens()) {
|
||||
st = new StringTokenizer(in.readLine().trim());
|
||||
}
|
||||
return st.nextToken();
|
||||
}
|
||||
|
||||
public String next(String delim) throws IOException {
|
||||
while (st == null || !st.hasMoreTokens()) {
|
||||
st = new StringTokenizer(in.readLine().trim());
|
||||
}
|
||||
return st.nextToken(delim);
|
||||
}
|
||||
|
||||
public String nextLine() throws IOException {
|
||||
st = null;
|
||||
return in.readLine();
|
||||
}
|
||||
|
||||
// public BigInteger nextBigInteger() throws IOException { return new BigInteger(next()); }
|
||||
|
||||
public byte nextByte() throws IOException { return Byte.parseByte(next()); }
|
||||
public byte nextByte(String delim) throws IOException { return Byte.parseByte(next(delim)); }
|
||||
public char nextChar() throws IOException { return next().charAt(0); }
|
||||
public char nextChar(String delim) throws IOException { return next(delim).charAt(0); }
|
||||
public double nextDouble() throws IOException { return Double.parseDouble(next()); }
|
||||
public double nextDouble(String delim) throws IOException { return Double.parseDouble(next(delim)); }
|
||||
public float nextFloat() throws IOException { return Float.parseFloat(next()); }
|
||||
public float nextFloat(String delim) throws IOException { return Float.parseFloat(next(delim)); }
|
||||
public int nextInt() throws IOException { return Integer.parseInt(next()); }
|
||||
public int nextInt(String delim) throws IOException { return Integer.parseInt(next(delim)); }
|
||||
public long nextLong() throws IOException { return Long.parseLong(next()); }
|
||||
public long nextLong(String delim) throws IOException { return Long.parseLong(next(delim)); }
|
||||
public short nextShort() throws IOException { return Short.parseShort(next()); }
|
||||
public short nextShort(String delim) throws IOException { return Short.parseShort(next(delim)); }
|
||||
} // Reader class
|
||||
|
||||
private static Reader in;
|
||||
private static PrintWriter out;
|
||||
|
||||
private static final int NUM_OF_TEST_CASES = 10; // TODO CHANGE NUMBER OF TEST CASES
|
||||
|
||||
// TODO CHANGE FILE NAMES
|
||||
private static final String INPUT_FILE_NAME = "src\\questinput.txt";
|
||||
private static final String OUTPUT_FILE_NAME = "output.txt";
|
||||
|
||||
private static boolean stdIn = true;
|
||||
private static boolean stdOut = true;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
String packageName = "";
|
||||
if (!stdIn || !stdOut) {
|
||||
try {
|
||||
packageName = o.getClass().getPackage().toString().split(" ")[1] + "/";
|
||||
} catch (NullPointerException e) {}
|
||||
}
|
||||
if (stdIn) in = new Reader(System.in);
|
||||
else in = new Reader(packageName + INPUT_FILE_NAME);
|
||||
if (stdOut) out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
|
||||
else out = new PrintWriter(new BufferedWriter(new FileWriter(packageName + OUTPUT_FILE_NAME)));
|
||||
|
||||
for (int i = 1; i <= NUM_OF_TEST_CASES; i++) {
|
||||
run(i);
|
||||
out.flush();
|
||||
}
|
||||
out.close();
|
||||
}
|
||||
|
||||
public static void run(int testCaseNum) throws IOException {
|
||||
String dna = in.nextLine();
|
||||
System.out.println(dna);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
6
ECOO_2018/.classpath
Normal file
6
ECOO_2018/.classpath
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
1
ECOO_2018/.gitignore
vendored
Normal file
1
ECOO_2018/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/bin/
|
||||
17
ECOO_2018/.project
Normal file
17
ECOO_2018/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ECOO_2018</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
11
ECOO_2018/.settings/org.eclipse.jdt.core.prefs
Normal file
11
ECOO_2018/.settings/org.eclipse.jdt.core.prefs
Normal file
@@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
30
ECOO_2018/src/Q1.java
Normal file
30
ECOO_2018/src/Q1.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q1 {
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
int num = Integer.parseInt(in.nextLine());
|
||||
String names = "";
|
||||
for(int i = 0; i<num; i++) {
|
||||
String challenger = in.nextLine();
|
||||
int space = challenger.indexOf(" ");
|
||||
if(isChallenger(challenger)) {
|
||||
names += challenger.substring(0, space) + " ";
|
||||
}
|
||||
}
|
||||
String[] namesSplit = names.split(" ");
|
||||
for(int j =0; j<namesSplit.length; j++) {
|
||||
System.out.println(namesSplit[j]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean isChallenger(String challenger) {
|
||||
int space = challenger.indexOf(" ");
|
||||
|
||||
if(Integer.parseInt(challenger.substring(space+1)) > 9001){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
32
ECOO_2018/src/Q3.java
Normal file
32
ECOO_2018/src/Q3.java
Normal file
@@ -0,0 +1,32 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q3 {
|
||||
public static String sRemoved;
|
||||
public static String removed;
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
sRemoved = in.nextLine();
|
||||
|
||||
while(!sRemoved.equals("done")) {
|
||||
removed += scan(sRemoved);
|
||||
}
|
||||
System.out.println(removed);
|
||||
|
||||
}
|
||||
public static String scan(String s) {
|
||||
|
||||
if(s.indexOf(":") != -1) {
|
||||
if(s.substring(s.indexOf(":" + 1)).indexOf(":") != -1){
|
||||
return s.substring(s.indexOf(":"), s.substring(s.indexOf(":" + 1)).indexOf(":"));
|
||||
}
|
||||
}
|
||||
sRemoved = "done";
|
||||
return "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
40
ECOO_2018/src/Q4.java
Normal file
40
ECOO_2018/src/Q4.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Q4 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//Integer.parseInt(s)
|
||||
Scanner in = new Scanner(System.in);
|
||||
|
||||
int num = Integer.parseInt(in.nextLine());
|
||||
String input = in.nextLine();
|
||||
String[] inputs = input.split(" ");
|
||||
int greatest = 0;
|
||||
|
||||
int regScore = 0;
|
||||
for(int i=0;i<inputs.length - 1;i+=2) {
|
||||
if(getHandValue(inputs, i) > greatest) {
|
||||
greatest = getHandValue(inputs, i);
|
||||
}
|
||||
}
|
||||
System.out.println(greatest);
|
||||
}
|
||||
|
||||
public static int getHandValue(String[] hand, int pairIndex) {
|
||||
int value = 0;
|
||||
for(int j = 0; j<pairIndex; j+=2) {
|
||||
value+=Integer.parseInt(hand[j]);
|
||||
}
|
||||
value += Integer.parseInt(hand[pairIndex]) + Integer.parseInt(hand[pairIndex + 1]);
|
||||
|
||||
|
||||
for(int j = pairIndex + 3; j<hand.length; j+=2) {
|
||||
value+=Integer.parseInt(hand[j]);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user