From f226b7c30d5819e8b2304fed449303b6042aa60a Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Fri, 10 Oct 2025 19:47:50 +0900 Subject: [PATCH] 20251010 baekjoon --- code_study/Baekjoon/java/_14938.java | 77 ++++++++++++++++++++++++++++ code_study/Baekjoon/python/1264.py | 12 +++++ 2 files changed, 89 insertions(+) create mode 100644 code_study/Baekjoon/java/_14938.java create mode 100644 code_study/Baekjoon/python/1264.py diff --git a/code_study/Baekjoon/java/_14938.java b/code_study/Baekjoon/java/_14938.java new file mode 100644 index 0000000..79668ee --- /dev/null +++ b/code_study/Baekjoon/java/_14938.java @@ -0,0 +1,77 @@ +import java.util.*; + +class Tuple implements Comparable { + int distance, node; + + Tuple(int distance, int node) { + this.distance = distance; + this.node = node; + } + + @Override + public int compareTo(Tuple other) { + return Integer.compare(this.distance, other.distance); + } +} + +public class _14938 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String[] line1 = sc.nextLine().split(" "); + int n = Integer.parseInt(line1[0]); + int m = Integer.parseInt(line1[1]); + int r = Integer.parseInt(line1[2]); + + String[] line2 = sc.nextLine().split(" "); + int[] items = new int[n+1]; + for(int i=1; i<=n; i++) items[i] = Integer.parseInt(line2[i-1]); + + @ SuppressWarnings("unchecked") + ArrayList[] graph = new ArrayList[n+1]; + for(int i=0; i<=n; i++) graph[i] = new ArrayList(); + + for(int i=0; i pq = new PriorityQueue<>(); + pq.add(new Tuple(0, start)); // (distance, node) + distance[start] = 0; + + while (!pq.isEmpty()) { + Tuple current = pq.poll(); + + if(current.distance > distance[current.node]) continue; + + for (Tuple next : graph[current.node]) { + if(distance[next.node] > distance[current.node] + next.distance) { + distance[next.node] = distance[current.node] + next.distance; + pq.add(new Tuple(distance[next.node], next.node)); + } + } + } + + int temp = 0; + for(int i=1; i<=n; i++) { + if(distance[i] <= m) temp += items[i]; + } + + result = Math.max(result, temp); + } + + System.out.println(result); + } +} diff --git a/code_study/Baekjoon/python/1264.py b/code_study/Baekjoon/python/1264.py new file mode 100644 index 0000000..83a45e2 --- /dev/null +++ b/code_study/Baekjoon/python/1264.py @@ -0,0 +1,12 @@ +while True : + cnt = 0 + s = input() + + if s == '#' : + break + + for c in s : + if c in ['a','e','i','o','u','A','E','I','O','U'] : + cnt += 1 + + print(cnt) \ No newline at end of file