Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3c36e01

Browse files
authored
Merge pull request #294 from yeongleej/main
[21주차] 이지영
2 parents 830036a + 557fa83 commit 3c36e01

File tree

3 files changed

+125
-0
lines changed

3 files changed

+125
-0
lines changed

‎BOJ/1000-5000번/JY_2170.java‎

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import java.io.*;
2+
import java.util.*;
3+
public class JY_2170 {
4+
5+
static class Pos implements Comparable<Pos> {
6+
int x, y;
7+
8+
public Pos(int x, int y) {
9+
super();
10+
this.x = x;
11+
this.y = y;
12+
}
13+
@Override
14+
public int compareTo(Pos other) {
15+
return this.x - other.x;
16+
}
17+
18+
@Override
19+
public String toString() {
20+
return "Pos [x=" + x + ", y=" + y + "]";
21+
}
22+
23+
}
24+
25+
public static void main(String[] args) throws IOException {
26+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
27+
StringTokenizer st = new StringTokenizer(br.readLine());
28+
29+
int N = Integer.parseInt(st.nextToken());
30+
31+
List<Pos> pList = new ArrayList<>();
32+
for(int i=0; i<N; i++) {
33+
st = new StringTokenizer(br.readLine());
34+
int x = Integer.parseInt(st.nextToken());
35+
int y = Integer.parseInt(st.nextToken());
36+
37+
pList.add(new Pos(x, y));
38+
}
39+
40+
// x기준으로 정렬
41+
Collections.sort(pList);
42+
43+
int s = pList.get(0).x;
44+
int e = pList.get(0).y;
45+
int ans = 0;
46+
for(int i=1; i<N; i++) {
47+
Pos now = pList.get(i);
48+
49+
// now.x가 end보다 작다면 겹침 -> end 갱신
50+
if(e >= now.x) {
51+
e = Math.max(e, now.y);
52+
}
53+
// 겹치지 않는 경우
54+
else {
55+
// 기존것 더해주고 새로 업데이트
56+
ans += (e - s);
57+
s = now.x;
58+
e = now.y;
59+
}
60+
}
61+
ans += (e - s);
62+
System.out.println(ans);
63+
64+
}
65+
66+
}

‎BOJ/1000-5000번/JY_2504.java‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import java.io.*;
2+
import java.util.*;
3+
public class JY_2504 {
4+
5+
public static void main(String[] args) throws IOException {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
8+
String line = br.readLine();
9+
10+
Stack<Character> stack = new Stack<>();
11+
12+
int ans = 0;
13+
int tmp = 1;
14+
for(int i=0; i<line.length(); i++) {
15+
char ch = line.charAt(i);
16+
// 열린괄호
17+
if(ch == '(') {
18+
stack.push(ch);
19+
tmp *= 2;
20+
} else if(ch == '[') {
21+
stack.push(ch);
22+
tmp *= 3;
23+
}
24+
// 닫힌 괄호
25+
else {
26+
if(stack.isEmpty()) {
27+
ans = 0;
28+
break;
29+
}
30+
// 올바르지 않은 괄호
31+
if((ch == ')' && stack.peek() == '[') || (ch == ']' && stack.peek() =='(')) {
32+
ans = 0;
33+
break;
34+
}
35+
// 이전 값이 올바른 괄호라면 값 저장
36+
if(ch == ')') {
37+
if(line.charAt(i-1)=='(') ans += tmp;
38+
tmp /= 2;
39+
} else {
40+
if(line.charAt(i-1)=='[') ans += tmp;
41+
tmp /= 3;
42+
}
43+
stack.pop();
44+
}
45+
}
46+
47+
if(!stack.isEmpty()) System.out.println(0);
48+
else System.out.println(ans);
49+
}
50+
51+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- https://school.programmers.co.kr/learn/courses/30/lessons/276035
2+
-- FrontEnd 개발자 찾기
3+
SELECT DISTINCT A.ID, A.EMAIL, A.FIRST_NAME, A.LAST_NAME
4+
FROM DEVELOPERS A
5+
JOIN SKILLCODES B
6+
ON A.SKILL_CODE & B.CODE = B.CODE
7+
WHERE CATEGORY = "Front End"
8+
ORDER BY A.ID

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /