Skip to content

Commit

Permalink
Feat:Add solution of #118
Browse files Browse the repository at this point in the history
  • Loading branch information
sa11k committed Jul 26, 2022
1 parent ba0fce5 commit 6e1b3cb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/BaekJoon/sa11k/10814/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{
public static class Person implements Comparable<Person>{
int age;
String name;

Person(int age, String name){
this.age = age;
this.name = name;
}

@Override
public int compareTo(Person o) {
return this.age - o.age;
}
}

public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
Person[] person = new Person[N];

for(int i = 0; i<N; i++){
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
person[i] = new Person(Integer.parseInt(st.nextToken()), st.nextToken());
}

Arrays.sort(person);

for(int i = 0; i<N; i++){
System.out.println(person[i].age + " " + person[i].name);
}

br.close();
}
}

0 comments on commit 6e1b3cb

Please sign in to comment.