Last active
October 18, 2020 15:16
-
-
Save chaidhat/71e9eaadd98ebe3dbe1190e219398d80 to your computer and use it in GitHub Desktop.
Kick Start round A 22/03/2020
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22-MAR-2020 | |
Chaidhat Chaimongkol | |
Patrick Ledoit | |
20th percentile | |
10921/13700 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.; | |
import java.io.; | |
// Chaidhat Chaimongkol | |
// 22 03 2020 | |
// Kickstart Round A Task B | |
public class Main { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int t = in.nextInt(); Scanner has functions to read ints, longs, strings, chars, etc. | |
for (int i = 1; i = t; ++i) { | |
int n = in.nextInt(); | |
int k = in.nextInt(); | |
int p = in.nextInt(); | |
int [][]plates = new int[n][k]; | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
for (int c2 = 0; c2 k; c2++) | |
{ | |
plates[c1][c2] = in.nextInt(); | |
} | |
} | |
for (int j = 0; j p; j++) | |
{ | |
int plateValues[][] = new int[n][k]; | |
add them all up | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
int acc = 0; | |
for (int c2 = 0; c2 k; c2++) | |
{ | |
acc += plates[c1][c2]; | |
plateValues[c1][c2] = acc; | |
System.out.println(p + c1 + , + c2 + + acc); | |
} | |
} | |
int ignoreColumns = 0; | |
if (p-j-1 k) | |
{ | |
ignoreColumns = k-(p-j-1); | |
} | |
int highest = 0; | |
int highestIndex = -1; | |
find the highest sum | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
System.out.println(p + (k-1-ignoreColumns)); | |
if (plateValues[c1][k - 1- ignoreColumns] highest) | |
{ | |
highest = plateValues[c1][k-1-ignoreColumns]; | |
highestIndex = c1; | |
} | |
} | |
subtract everythingt by the first cell | |
-10 -20 -10 -30 | |
int c2 = 0; | |
while (plates[highestIndex][c2] == 0 && c2 k ) { | |
c2++; | |
} find the fsirst one without a negative | |
System.out.println(highestIndex + ,+c2 + , + plates[highestIndex][c2]); | |
plates[highestIndex][c2] = 0; | |
} | |
} | |
} | |
} | |
10 10 100 30 | |
-10 10 100 30 | |
-10 0 90 20 | |
-10 20 120 150 | |
-80 130 140 190 | |
-10 20 120 150 | |
10 20 120 150 | |
-10 10 110 140 | |
-10 -10 -100 30 | |
-80 -50 60 60 | |
-80 -80 | |
15 -65 | |
20 -30 | |
add them all up | |
find the highest sum | |
remove the first of the highest sum | |
subtract everything by the first cell | |
ignore columns which if larger than plates | |
Loops until no more plTES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Did not submit | |
import java.util.; | |
import java.io.; | |
// Chaidhat Chaimongkol | |
// 22 03 2020 | |
// Kickstart Round A Task B | |
public class Main { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int t = in.nextInt(); Scanner has functions to read ints, longs, strings, chars, etc. | |
for (int i = 1; i = t; ++i) { | |
int n = in.nextInt(); | |
int k = in.nextInt(); | |
int p = in.nextInt(); | |
int [][]plates = new int[n][k]; | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
for (int c2 = 0; c2 k; c2++) | |
{ | |
plates[c1][c2] = in.nextInt(); | |
} | |
} | |
for (int j = 0; j p; j++) | |
{ | |
int plateValues[][] = new int[n][k]; | |
add them all up | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
int acc = 0; | |
for (int c2 = 0; c2 k; c2++) | |
{ | |
acc += plates[c1][c2]; | |
plateValues[c1][c2] = acc; | |
System.out.println(p + c1 + , + c2 + + acc); | |
} | |
} | |
int ignoreColumns = 0; | |
if (p-j-1 k) | |
{ | |
ignoreColumns = k-(p-j-1); | |
} | |
int highest = 0; | |
int highestIndex = -1; | |
find the highest sum | |
for (int c1 = 0; c1 n; c1++) | |
{ | |
System.out.println(p + (k-1-ignoreColumns)); | |
if (plateValues[c1][k - 1- ignoreColumns] highest) | |
{ | |
highest = plateValues[c1][k-1-ignoreColumns]; | |
highestIndex = c1; | |
} | |
} | |
subtract everythingt by the first cell | |
-10 -20 -10 -30 | |
int c2 = 0; | |
while (plates[highestIndex][c2] == 0 && c2 k ) { | |
c2++; | |
} find the fsirst one without a negative | |
System.out.println(highestIndex + ,+c2 + , + plates[highestIndex][c2]); | |
plates[highestIndex][c2] = 0; | |
} | |
} | |
} | |
} | |
10 10 100 30 | |
-10 10 100 30 | |
-10 0 90 20 | |
-10 20 120 150 | |
-80 130 140 190 | |
-10 20 120 150 | |
10 20 120 150 | |
-10 10 110 140 | |
-10 -10 -100 30 | |
-80 -50 60 60 | |
-80 -80 | |
15 -65 | |
20 -30 | |
add them all up | |
find the highest sum | |
remove the first of the highest sum | |
subtract everything by the first cell | |
ignore columns which if larger than plates | |
Loops until no more plTES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment