-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |