ALGORITHM ๐Ÿค–/Baekjoon

๋ฐฑ์ค€
https://www.acmicpc.net/problem/2012 2012๋ฒˆ: ๋“ฑ์ˆ˜ ๋งค๊ธฐ๊ธฐ ์ฒซ์งธ ์ค„์— ์ž์—ฐ์ˆ˜ N์ด ์ฃผ์–ด์ง„๋‹ค. (1 ≤ N ≤ 500,000) ๋‘˜์งธ ์ค„๋ถ€ํ„ฐ N๊ฐœ์˜ ์ค„์— ๊ฑธ์ณ ๊ฐ ์‚ฌ๋žŒ์˜ ์˜ˆ์ƒ ๋“ฑ์ˆ˜๊ฐ€ ์ˆœ์„œ๋Œ€๋กœ ์ฃผ์–ด์ง„๋‹ค. ์˜ˆ์ƒ ๋“ฑ์ˆ˜๋Š” 500,000 ์ดํ•˜์˜ ์ž์—ฐ์ˆ˜์ด๋‹ค. www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] expectRank = new int[n]; // ์˜ˆ์ƒ ๋“ฑ์ˆ˜๋ฅผ ๋‹ด์„ ๋ฐฐ์—ด long disSat = 0; // ์ตœ์†Œ ๋ถˆ๋งŒ๋„์˜ ํ•ฉ for (int i..
https://www.acmicpc.net/problem/1543 1543๋ฒˆ: ๋ฌธ์„œ ๊ฒ€์ƒ‰ ์„ธ์ค€์ด๋Š” ์˜์–ด๋กœ๋งŒ ์ด๋ฃจ์–ด์ง„ ์–ด๋–ค ๋ฌธ์„œ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค๋ ค๊ณ  ํ•œ๋‹ค. ์ด ํ•จ์ˆ˜๋Š” ์–ด๋–ค ๋‹จ์–ด๊ฐ€ ์ด ๋ช‡ ๋ฒˆ ๋“ฑ์žฅํ•˜๋Š”์ง€ ์„ธ๋ ค๊ณ  ํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜, ์„ธ์ค€์ด์˜ ํ•จ์ˆ˜๋Š” ์ค‘๋ณต๋˜์–ด ์„ธ๋Š” ๊ฒƒ์€ ๋นผ๊ณ  ์„ธ์•ผ ํ•œ www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String document = sc.nextLine(); String search = sc.nextLine(); int count = 0; // ์ค‘๋ณต๋˜์ง€ ์•Š๊ณ  ๊ฒ€์ƒ‰ํ•˜๊ณ  ์‹ถ์€ ๋‹จ์–ด๊ฐ€ ๋“ฑ์žฅํ•  ์ˆ˜ ..
https://www.acmicpc.net/problem/2667 2667๋ฒˆ: ๋‹จ์ง€๋ฒˆํ˜ธ๋ถ™์ด๊ธฐ ๊ณผ ๊ฐ™์ด ์ •์‚ฌ๊ฐํ˜• ๋ชจ์–‘์˜ ์ง€๋„๊ฐ€ ์žˆ๋‹ค. 1์€ ์ง‘์ด ์žˆ๋Š” ๊ณณ์„, 0์€ ์ง‘์ด ์—†๋Š” ๊ณณ์„ ๋‚˜ํƒ€๋‚ธ๋‹ค. ์ฒ ์ˆ˜๋Š” ์ด ์ง€๋„๋ฅผ ๊ฐ€์ง€๊ณ  ์—ฐ๊ฒฐ๋œ ์ง‘์˜ ๋ชจ์ž„์ธ ๋‹จ์ง€๋ฅผ ์ •์˜ํ•˜๊ณ , ๋‹จ์ง€์— ๋ฒˆํ˜ธ๋ฅผ ๋ถ™์ด๋ ค ํ•œ๋‹ค. ์—ฌ www.acmicpc.net import java.util.*; import java.io.*; public class Main { static int[][] arr; static boolean[][] visited; static int N, count; static ArrayList result; static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; public..
https://www.acmicpc.net/problem/2468 2468๋ฒˆ: ์•ˆ์ „ ์˜์—ญ ์žฌ๋‚œ๋ฐฉ์žฌ์ฒญ์—์„œ๋Š” ๋งŽ์€ ๋น„๊ฐ€ ๋‚ด๋ฆฌ๋Š” ์žฅ๋งˆ์ฒ ์— ๋Œ€๋น„ํ•ด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ผ์„ ๊ณ„ํšํ•˜๊ณ  ์žˆ๋‹ค. ๋จผ์ € ์–ด๋–ค ์ง€์—ญ์˜ ๋†’์ด ์ •๋ณด๋ฅผ ํŒŒ์•…ํ•œ๋‹ค. ๊ทธ ๋‹ค์Œ์— ๊ทธ ์ง€์—ญ์— ๋งŽ์€ ๋น„๊ฐ€ ๋‚ด๋ ธ์„ ๋•Œ ๋ฌผ์— ์ž ๊ธฐ์ง€ ์•Š๋Š” www.acmicpc.net import java.util.*; import java.io.*; public class Main { static int[][] arr; static boolean[][] visited; static int N; static int[] dx = {-1, 1, 0, 0}; static int[] dy = {0, 0, -1, 1}; static int[] result; public static void m..
https://www.acmicpc.net/problem/1459 1459๋ฒˆ: ๊ฑท๊ธฐ ์„ธ์ค€์ด๋Š” ํ•™๊ต์—์„œ ์ง‘์œผ๋กœ ๊ฐ€๋ ค๊ณ  ํ•œ๋‹ค. ๋„์‹œ์˜ ํฌ๊ธฐ๋Š” ๋ฌดํ•œ๋Œ€์ด๊ณ , ๋„์‹œ์˜ ์„ธ๋กœ ๋„๋กœ๋Š” ๋ชจ๋“  ์ •์ˆ˜ x์ขŒํ‘œ๋งˆ๋‹ค ์žˆ๊ณ , ๊ฐ€๋กœ ๋„๋กœ๋Š” ๋ชจ๋“  ์ •์ˆ˜ y์ขŒํ‘œ๋งˆ๋‹ค ์žˆ๋‹ค. ์„ธ์ค€์ด๋Š” ํ˜„์žฌ (0, 0)์— ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ( www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); // ์ง‘์˜ ์œ„์น˜ x์ขŒํ‘œ long y = sc.nextLong(); // ์ง‘์˜ ์œ„์น˜ y์ขŒํ‘œ long w = sc.nextLong(); // ๊ฑธ์–ด์„œ..
https://www.acmicpc.net/problem/25206 25206๋ฒˆ: ๋„ˆ์˜ ํ‰์ ์€ ์ธํ•˜๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐ๊ณตํ•™๊ณผ๋ฅผ ์กธ์—…ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, ์ „๊ณตํ‰์ ์ด 3.3 ์ด์ƒ์ด๊ฑฐ๋‚˜ ์กธ์—…๊ณ ์‚ฌ๋ฅผ ํ†ต๊ณผํ•ด์•ผ ํ•œ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์•„๋ฟ”์‹ธ, ์น˜ํ›ˆ์ด๋Š” ๊นœ๋นกํ•˜๊ณ  ์กธ์—…๊ณ ์‚ฌ๋ฅผ ์‘์‹œํ•˜์ง€ ์•Š์•˜๋‹ค๋Š” ์‚ฌ์‹ค์„ ๊นจ๋‹ฌ์•˜๋‹ค! ์น˜ www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double score = 0; // ๊ณผ๋ชฉํ‰์  double credit = 0; // ํ•™์  double sum = 0; // ํ•™์ ์˜ ์ดํ•ฉ double all = 0; // (ํ•™์  × ๊ณผ๋ชฉํ‰์ )์˜..
https://www.acmicpc.net/problem/2675 2675๋ฒˆ: ๋ฌธ์ž์—ด ๋ฐ˜๋ณต ๋ฌธ์ž์—ด S๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ํ›„์—, ๊ฐ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•ด ์ƒˆ ๋ฌธ์ž์—ด P๋ฅผ ๋งŒ๋“  ํ›„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์ฆ‰, ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ๋ฌธ์ž๋ฅผ R๋ฒˆ ๋ฐ˜๋ณตํ•˜๋Š” ์‹์œผ๋กœ P๋ฅผ ๋งŒ๋“ค๋ฉด ๋œ๋‹ค www.acmicpc.net import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { int r = sc.nextInt(); String s = sc.next(); Stri..
daxx0ne
'ALGORITHM ๐Ÿค–/Baekjoon' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (3 Page)