-
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
12 changed files
with
211 additions
and
5 deletions.
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
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,35 @@ | ||
#include <iostream> | ||
#include <vector> | ||
using namespace std; | ||
|
||
bool check(vector <int>& v, int n, long long length); | ||
int binary_serach(vector <int>& v, int n); | ||
|
||
int main() { | ||
int k, n; | ||
cin >> k >> n; | ||
vector <int> v(k); | ||
for (auto& i : v) { | ||
cin >> i; | ||
} | ||
cout << binary_serach(v, n); | ||
return 0; | ||
} | ||
|
||
bool check(vector <int>& v, int n, long long length) { | ||
int cnt = 0; | ||
for (const auto& i : v) { | ||
cnt += i / length; | ||
} | ||
return cnt >= n; | ||
} | ||
|
||
int binary_serach(vector <int>& v, int n) { | ||
long long lo = 1, hi = 2147483648; //μλ₯Ό μ μλ λμ μ λ²μ | ||
while (lo + 1 < hi) { | ||
long long mid = (lo + hi) / 2; | ||
if (check(v, n, mid)) lo = mid; | ||
else hi = mid; | ||
} | ||
return lo; | ||
} |
File renamed without changes.
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"); | ||
} |
Binary file not shown.
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,22 @@ | ||
chemical = input() | ||
stack = [] | ||
atomic = {'H':1, 'C':12, 'O':16} # μμλ λμ λ리 | ||
|
||
for c in chemical: | ||
if c =='(': | ||
stack.append(c) | ||
elif c == 'H' or c == 'C' or c == 'O': | ||
stack.append(atomic[c]) # μ λ ₯λ°μ μμμ μμλμ μ€νμ μΆκ° | ||
elif c == ')': | ||
temp = 0 # λ«λ κ΄νΈλ₯Ό λ§λλ©΄ temp μ΄κΈ°ν | ||
while True: | ||
if stack[-1] == '(': # μ€νμ topμ΄ μ¬λ κ΄νΈλ©΄ | ||
stack.pop() # μ€νμμ μ¬λ κ΄νΈλ₯Ό μμ | ||
stack.append(temp) # μ€νμ temp μΆκ° | ||
break | ||
else: | ||
temp += stack.pop() # μ¬λ κ΄νΈ μ κΉμ§μ μ€ν μμ λͺ¨λ κ°μ tempμ μ μ₯ | ||
else: # cκ° μ«μλΌλ©΄ | ||
stack.append(stack.pop()*int(c)) # μ€νμ top κ°κ³Ό μ«μλ₯Ό κ³±νμ¬ μ€νμ μΆκ° | ||
|
||
print(sum(stack)) |
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; | ||
} |
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,41 @@ | ||
# 11404 : νλ‘μ΄λ | ||
import sys | ||
|
||
input = sys.stdin.readline | ||
INF = float('inf') # μ΅λκ° μ μ | ||
|
||
# λ Έλμ κ°μ(n)κ³Ό κ°μ μ κ°μ(m) μ λ ₯ | ||
n = int(input()) # λμμ κ°μ n | ||
m = int(input()) # λ²μ€μ κ°μ m | ||
|
||
# 2μ°¨μ 리μ€νΈ (κ·Έλν νν) λ§λ€κ³ , 무νλλ‘ μ΄κΈ°ν(νλ‘μ΄λ-μμ = μ΄μ°¨μ λ°°μ΄) | ||
graph = [[INF] * (n + 1) for _ in range(n + 1)] | ||
|
||
# iμμ jλ‘ κ° μ μλ κ²½μ°, | ||
# μκΈ° μμ μμ μκΈ° μμ μΌλ‘ κ°λ λΉμ©μ 0μΌλ‘ μ΄κΈ°ν(λκ°μ μ ν΄λΉνλ λΆλΆ)) | ||
for i in range(1, n + 1): | ||
for j in range(1, n + 1): | ||
if i == j: | ||
graph[i][j] = 0 | ||
|
||
# κ° κ°μ μ λν μ 보λ₯Ό μ λ ₯λ°μ, κ·Έ κ°μΌλ‘ μ΄κΈ°ν | ||
for _ in range(m): | ||
# A -> Bλ‘ κ°λ λΉμ©μ CλΌκ³ μ€μ | ||
i, j, cost = map(int, input().split()) | ||
if graph[i][j] > cost: # μμ λμμ λμ°© λμ μ°κ²°νλ λ Έμ νλκ° x | ||
graph[i][j] = cost | ||
|
||
# μ νμμ λ°λΌ νλ‘μ΄λ μμ μκ³ λ¦¬μ¦μ μν(3μ€ forλ¬Έ) | ||
for k in range(1, n + 1): | ||
for i in range(1, n + 1): | ||
for j in range(1, n + 1): | ||
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]) | ||
|
||
# μνλ κ²°κ³Όλ₯Ό μΆλ ₯ | ||
for i in range(1, n + 1): | ||
for j in range(1, n + 1): | ||
if graph[i][j] == INF: | ||
print(0, end=' ') | ||
else: | ||
print(graph[i][j], end=' ') | ||
print() |