Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions 11월16일/초중급/1923012_2246.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int n = Integer.parseInt(br.readLine());

Condo[] condoes = new Condo[n];

for(int i=0; i<n; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
condoes[i] = new Condo(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
}

//거리 순으로 오름차순 정렬하는 Comparator
Comparator<Condo> cpd = new Comparator<Condo>() {
@Override
public int compare (Condo c1, Condo c2) {
if(c1.getD() > c2.getD()) return 1;
else if (c1.getD() == c2.getD()) {
if(c1.getC() < c2.getC()) return 1;
else return -1;
}
else return -1;
}
};

//가격 순으로 오름차순 정렬하는 Comparator
Comparator<Condo> cpc = new Comparator<Condo>() {
@Override
public int compare(Condo c1, Condo c2) {
if(c1.getC() > c2.getC()) return 1;
else if(c1.getC() == c2.getC()) {
if(c1.getD() < c2.getD()) return 1;
else return -1;
}
else return -1;
}
};

//거리 순으로 오름차순 정렬
Arrays.sort(condoes, cpd);

//모든 콘도에 대하여, 나보다 바닷가에 가까운 콘도 중 가격이 더 싸거나 같은 것이 있는지 판단
for(int i=0; i<n; i++) {
for(int j=0; j<i; j++) {
if (condoes[i].getC()>=condoes[j].getC()) {
condoes[i].setCheck(false);
break;
}
}
}


//가격 순으로 오름차순 정렬
Arrays.sort(condoes, cpc);

//모든 콘도에 대하여, 나보다 싼 콘도 중 거리가 바닷가에 가깝거나 같은 것이 있는지 판단
for(int i=0; i<n; i++) {
for(int j=0; j<i; j++) {
if (condoes[i].getD() >= condoes[j].getD()) {
condoes[i].setCheck(false);
break;
}
}
}


int answer = 0;
for(Condo c: condoes) {
if(c.getCheck()) answer++;
}

System.out.print(answer);
}

}

class Condo {
private int d; //거리
private int c; //가격
private boolean check; //false가 되면 후보 탈락
public Condo(int d, int c) {
this.d = d;
this.c = c;
this.check = true;
}
public int getD() {return d;}
public int getC() {return c;}
public void setCheck(boolean check) {this.check = check;}
public boolean getCheck() {return check;}
}
36 changes: 36 additions & 0 deletions 11월16일/초중급/1923012_4436.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;

public class Main {

public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String input = null;

while((input=br.readLine()) != (null)) {
long n = Long.parseLong(input);

//0부터 9까지의 숫자가 담겨있는 해시셋 선언
HashSet<Character> hs = new HashSet<Character>();
for(int i=0; i<10; i++) hs.add((char)(i+'0'));

//초기값이 0인 k 선언
long k = 0;
while(true) {
k++; //k를 1 증가시킴
String str = Long.toString(k*n); //곱셈
for(int i=0; i<str.length(); i++) hs.remove(str.charAt(i)); //곱셈 결과값에 등장하는 모든 숫자를 해시셋에서 제거
if(hs.isEmpty()) break; //해시셋이 텅 비게 되었다면 정답이 도출된 것이므로 break
}

System.out.println(k);
}

}

}