Skip to content

Commit

Permalink
Merge branch 'main' into 10-pu2rile
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2rile committed Jul 22, 2024
2 parents 2b9bfa9 + a4360da commit 76a40d0
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
27 changes: 27 additions & 0 deletions pu2rile/κ΅¬ν˜„/μ˜€λŠ˜λ„ μ‘Œλ‹€.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>

int main() {
int j[9];
int g[9];
int win = 0;
int j_score = 0;
int g_score = 0;

for (int i=0 ; i<9; i++) { //μ œλ―Έλ‹ˆμŠ€ 점수 μž…λ ₯
scanf("%d", &j[i]);
}
for (int i=0 ; i<9; i++) { //κ±Έλ¦¬λ²„μŠ€ 점수 μž…λ ₯
scanf("%d", &g[i]);
}

for (int i=0 ; i<9; i++) {
j_score += j[i]; //μ œλ―Έλ‹ˆμŠ€ 점수 λˆ„μ ν•©(j_score == 총 점수)
if (j_score > g_score) //점수 비ꡐ
win = 1; //μ œλ―Έλ‹ˆμŠ€κ°€ 이겼닀면 win = 1
g_score += g[i]; //κ±Έλ¦¬λ²„μŠ€ 점수 λˆ„μ ν•©(g_score == 총 점수)
}
if (j_score < g_score && win == 1) //μ œλ―Έλ‹ˆμŠ€κ°€ μ‘Œμ§€λ§Œ μ œλ―Έλ‹ˆμŠ€κ°€ 이긴 적이 μžˆλ‹€λ©΄(μ—­μ „νŒ¨)
printf("Yes\n");
else
printf("No\n");
}
5 changes: 4 additions & 1 deletion suhyun113/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
| 3μ°¨μ‹œ | 2024.04.02 | 그리디 | [κ±°μŠ€λ¦„λˆ](https://www.acmicpc.net/problem/14916) | [#12](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/12) |
| 4μ°¨μ‹œ | 2024.04.06 | DP | [ν”Όλ³΄λ‚˜μΉ˜ 수 5](https://www.acmicpc.net/problem/10870) | [#16](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/16) |
| 5μ°¨μ‹œ | 2024.04.10 | μŠ€νƒ | [크레인 μΈν˜• 뽑기 κ²Œμž„](https://school.programmers.co.kr/learn/courses/30/lessons/64061) | [#19](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/19) |
| 6μ°¨μ‹œ | 2024.04.14 | μŠ€νƒ | [컨트둀 제트](https://school.programmers.co.kr/learn/courses/30/lessons/120853) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/21) |
| 6μ°¨μ‹œ | 2024.04.14 | μŠ€νƒ | [컨트둀 제트](https://school.programmers.co.kr/learn/courses/30/lessons/120853) | [#21](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/21) |
| 7μ°¨μ‹œ | 2024.05.09 | 트리 | [μ›μˆ­μ΄ 맀달기](https://www.acmicpc.net/problem/2716) | [#31](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/31) |
| 8μ°¨μ‹œ | 2024.05.14 | μˆ˜ν•™ | [μ–΄λ¦° μ™•μž](https://www.acmicpc.net/problem/1004) | [#32](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/32) |
| 9μ°¨μ‹œ | 2024.05.28 | λ‹€μ΅μŠ€νŠΈλΌ | [μ΅œμ†ŒλΉ„μš© κ΅¬ν•˜κΈ°](https://www.acmicpc.net/problem/1916) | [#33](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/33) |
36 changes: 36 additions & 0 deletions suhyun113/λ‹€μ΅μŠ€νŠΈλΌ/9-suhyun113.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 1916 : μ΅œμ†ŒλΉ„μš© κ΅¬ν•˜κΈ°

import heapq

INF = float('inf') # μ΅œλŒ€κ°’ μ •μ˜

N = int(input()) # λ„μ‹œμ˜ 개수(λ…Έλ“œ)
M = int(input()) # λ²„μŠ€μ˜ 개수(에지)

graph = [[] for _ in range(N+1)] # κ·Έλž˜ν”„ 인접 리슀트둜 μ΄ˆκΈ°ν™”(λ°©λ¬Έν•˜μ§€ μ•Šμ€ λ…Έλ“œλ“€)
distance = [INF] * (N+1) # 각 λ…Έλ“œκΉŒμ§€μ˜ 거리 λ¬΄ν•œλŒ€λ‘œ μ΄ˆκΈ°ν™”

for _ in range(M):
x, y, cost = map(int, input().split()) # x -> y λ„μ‹œλ‘œ κ°€λŠ” 데 ν•„μš”ν•œ λΉ„μš© cost
graph[x].append([y, cost]) # κ·Έλž˜ν”„μ— 에지 μΆ”κ°€

start, end = map(int, input().split()) # 좜발, 도착 λ…Έλ“œ μž…λ ₯ λ°›κΈ°

# λ‹€μ΅μŠ€νŠΈλΌ μ•Œκ³ λ¦¬μ¦˜
def Dijkstra(start):
q = [] # μš°μ„ μˆœμœ„ 큐 생성
heapq.heappush(q, [0, start]) # μΆœλ°œν•  λ„μ‹œ 큐에 λ„£κΈ°([거리, λ…Έλ“œ] ν˜•νƒœ)
distance[start] = 0 # μ‹œμž‘ λ„μ‹œμ˜ 거리 0으둜 μ΄ˆκΈ°ν™”

while q: # 큐가 빌 λ•ŒκΉŒμ§€ 반볡
weight, node = heapq.heappop(q) # ν˜„μž¬ λ…Έλ“œκΉŒμ§€μ˜ 거리, ν˜„μž¬ λ…Έλ“œ(νμ—μ„œ κ°€μž₯ μž‘μ€ κ°’)
if distance[node] < weight: # ν˜„μž¬ λ…Έλ“œκ°€ 이미 처리된 λ…Έλ“œμΈμ§€ 확인
continue
for n, w in graph[node]:
cost = w + weight # ν˜„μž¬ λ…Έλ“œλ₯Ό 톡해 인접 λ…Έλ“œκΉŒμ§€ κ°€λŠ” μƒˆλ‘œμš΄ 거리 계산
if distance[n] > cost: # μƒˆλ‘œμš΄ 거리가 기쑴에 μ €μž₯된 거리보닀 짧은지 확인
distance[n] = cost # μ΅œλ‹¨ 거리 κ°±μ‹ 
heapq.heappush(q, [cost, n]) # 인접 λ…Έλ“œλ₯Ό μš°μ„ μˆœμœ„ 큐에 μΆ”κ°€

Dijkstra(start)
print(distance[end])
42 changes: 42 additions & 0 deletions suhyun113/μˆ˜ν•™/8-suhyun113.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 1004 : μ–΄λ¦° μ™•μž

#include <iostream>
#include <cmath>
using namespace std;

int main() {
int T; // ν…ŒμŠ€νŠΈ μΌ€μ΄μŠ€μ˜ 개수
int x1, y1, x2, y2; // 좜발점, 도착점
int n; // ν–‰μ„±μ˜ 개수
int cx, cy, r; // ν–‰μ„±κ³„μ˜ 쀑점과 λ°˜μ§€λ¦„

cin >> T;
while(T--) {
cin >> x1 >> y1 >> x2 >> y2;
cin >> n;

int enter = 0; // μ§„μž… 횟수
int departure = 0; // μ΄νƒˆ 횟수
int count = 0; // μ΅œμ’… μ§„μž…/μ΄νƒˆ 횟수

while(n--) {
cin >> cx >> cy >> r;
float startDistance = sqrt(pow(cx - x1, 2) + pow(cy - y1, 2)); // 좜발점과 원 μ‚¬μ΄μ˜ 거리
float endDistance = sqrt(pow(cx - x2, 2) + pow(cy - y2, 2)); // 도착점과 원 μ‚¬μ΄μ˜ 거리

if (startDistance < r){ // 좜발점이 원 내뢀에 있고,
if (endDistance > r) { // 도착점이 원 외뢀에 있음
departure++; // 좜발점 ν¬ν•¨ν•˜λŠ” ν–‰μ„± -> μ΄νƒˆ 횟수 증가
}
}
if (startDistance > r) { // 좜발점이 원 외뢀에 있고,
if (endDistance < r) { // 도착점이 원 내뢀에 있음
enter++; // 도착점 ν¬ν•¨ν•˜λŠ” ν–‰μ„± -> μ§„μž… 회수 증가
}
}
}
count = enter + departure; // μ΅œμ’… μ§„μž…/μ΄νƒˆ 횟수
cout << count << endl;
}
return 0;
}

0 comments on commit 76a40d0

Please sign in to comment.