μ΄λ ₯μλ₯Ό μμ¦ λ€μλ³΄κ³ μλ€. μ΅μ νλ₯Ό ν΄λ³΄λ €κ³ νμ§λ§ μ·¨μ νμ λ ν΄λμκ² μμ΄μ λ΄μ© μ±μ°κΈ°κ° μκ°λ³΄λ€ λ§λ§μΉ μλ€. λ μ νΉνΉ μ°λλ° μ΄λ ₯μλ μΈκ² μκ³ ,,, μ΄λμ λ νλ μκ°μ΄λ€. μ₯λ§κ° κΈ°λλλ 7μ λμ§Έ μ£Όλ₯Ό λλμλ³Έλ€.
import java.io.*;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
Solution s = new Solution();
System.out.println(s.solution(getInput(br), getInput(br)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static int[][] getInput(BufferedReader br) throws IOException {
String[] dimensions = br.readLine().split(" ");
int rows = Integer.parseInt(dimensions[0]);
int cols = Integer.parseInt(dimensions[1]);
int[][] result = new int[rows][cols];
for (int i = 0; i < rows; i++) {
String[] line = br.readLine().split(" ");
for (int j = 0; j < cols; j++) {
result[i][j] = Integer.parseInt(line[j]);
}
}
return result;
}
}
class Solution {
public String solution(int[][] matrix1, int[][] matrix2) {
Calculator c = new Calculator(matrix1, matrix2);
return c.getAnswer();
}
private class Calculator {
int[][] matrix1;
int[][] matrix2;
int[][] result;
public Calculator(int[][] matrix1, int[][] matrix2) {
this.matrix1 = matrix1;
this.matrix2 = matrix2;
this.result = new int[matrix1.length][matrix2[0].length];
}
public String getAnswer() {
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
result[i][j] = calc(i, j);
}
}
return getResult();
}
private int calc(int x, int y) {
int[] xMatrix = matrix1[x];
int[] yMatrix = getYMatrix(y);
int result = 0;
for (int i = 0; i < xMatrix.length; i++) {
result += xMatrix[i] * yMatrix[i];
}
return result;
}
private int[] getYMatrix(int y) {
int[] result = new int[matrix2.length];
for (int i = 0; i < matrix2.length; i++) {
result[i] = matrix2[i][y];
}
return result;
}
private String getResult() {
StringBuilder answer = new StringBuilder();
for (int i = 0; i < result.length; i++) {
for (int j = 0; j < result[i].length; j++) {
answer.append(result[i][j]).append(" ");
}
answer.append("\n");
}
return answer.toString();
}
}
}
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
String[] tokens = br.readLine().split(" ");
int len = Integer.parseInt(tokens[0]);
int target = Integer.parseInt(tokens[1]);
Solution s = new Solution();
System.out.println(s.solution(getInput(br, len), target));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static int[][] getInput(BufferedReader br, int len) throws IOException {
int[][] result = new int[len][4];
for (int i = 0; i < result.length; i++) {
String[] line = br.readLine().split(" ");
for (int j = 0; j < result[i].length; j++) {
result[i][j] = Integer.parseInt(line[j]);
}
}
return result;
}
}
class Solution {
public int solution(int[][] countries, int target) {
Country[] order = new Country[countries.length];
for (int i = 0; i < countries.length; i++) {
int[] country = countries[i];
int name = country[0];
int gold = country[1];
int silver = country[2];
int bronze = country[3];
order[i] = new Country(name, gold, silver, bronze);
}
Arrays.sort(order);
order[0].rank = 1;
rankCountry(order);
return getOrder(target, order);
}
private void rankCountry(Country[] order) {
for (int i = 1; i < order.length; i++) {
if (isSameRank(order[i-1], order[i])) {
order[i].rank = order[i-1].rank;
} else {
order[i].rank = i + 1;
}
}
}
private boolean isSameRank(Country prev, Country cur) {
return cur.gold == prev.gold && cur.silver == prev.silver && cur.bronze == prev.bronze;
}
private int getOrder(int target, Country[] order) {
for (Country country : order) {
if (country.name == target) {
return country.rank;
}
}
return -1;
}
private class Country implements Comparable<Country> {
int name;
int gold;
int silver;
int bronze;
int rank = 0;
public Country(int name, int gold, int silver, int bronze) {
this.name = name;
this.gold = gold;
this.silver = silver;
this.bronze = bronze;
}
@Override
public int compareTo(Country o) {
if (this.gold == o.gold && this.silver == o.silver) {
return o.bronze - this.bronze;
} else if (this.gold == o.gold) {
return o.silver - this.silver;
}
return o.gold - this.gold;
}
}
}