전체 글
-
CodeForces #448C Painting Fence [java]알고리즘 구현 2020. 4. 9. 14:59
import java.util.Scanner; public class PaintingFence_448C { static int[] a; public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); a = new int[n]; int result = 0; for (int i = 0; i < n; i++) { a[i] = scan.nextInt(); } result = func(0, n); System.out.println(result); scan.close(); } public static int func(int s, int e) { if (s != e) { int vans, han..
-
CodeForces #158B Taxi [java]알고리즘 구현 2020. 4. 3. 23:02
import java.util.Scanner; public class Taxi_158B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int[] s = new int[n]; int[] num = new int[4]; for (int i = 0; i = num[0]) { num[0] = 0; } else { num[0] -= b; } int c = num[1] / 2; if ..
-
CodeForces #160A Twins [java]알고리즘 구현 2020. 4. 3. 23:01
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Twins_160A { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); List a = new ArrayList(); int sum = 0; for (int i = 0; i < n; i++) { a.add(scan.nextInt()); sum += a.get(i); } Collections.sort(a, Collections.reverseOrder()); i..
-
CodeForces #734B Anton And Digits [java]알고리즘 구현 2020. 4. 3. 22:58
import java.util.Scanner; public class AntonAndDigits_734B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int k2, k3, k5, k6; k2 = scan.nextInt(); k3 = scan.nextInt(); k5 = scan.nextInt(); k6 = scan.nextInt(); // 32, 256 int a = Math.min(Math.min(k2, k5), k6); if (a == k2) { System.out.println(a * 256); } else { int b = Math.min(k2 - a, k3); System.out.println(..
-
CodeForces #466C Number Of Ways [java]알고리즘 구현 2020. 3. 23. 23:19
import java.util.Scanner; public class NumberOfWays_466C { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt() + 1; long unit; long[] a = new long[n]; long[] pre = new long[n]; for (int i = 1; i < n; i++) { a[i] = scan.nextLong(); pre[i] = pre[i - 1] + a[i]; } if (pre[n - 1] % 3 != 0) { System.out.println(0); } else { unit = pre[n - 1] / 3; long..
-
CodeForces #1285B Just Eat It [java]알고리즘 구현 2020. 3. 23. 23:18
import java.util.Scanner; public class JustEatIt_1285B { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); long[] a; long pre = 0, po = 0; int n; for (int i = 0; i < t; i++) { n = scan.nextInt(); a = new long[n]; boolean yes = true; pre = 0; po = 0; for (int j = 0; j < n; j++) { a[j] = scan.nextLong(); pre = pre + a[j]; if (pre 0; j--) { po =..
-
CodeForces #1003C Intense Heat [java]알고리즘 구현 2020. 3. 23. 23:17
import java.util.Scanner; public class IntenseHeat_1003C { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n, k; n = scan.nextInt()+1; // days k = scan.nextInt(); // mininum of days in a segment int[] a = new int[n]; long[] pre = new long[n]; double max = 0; for (int i = 1; i < n; i++) { a[i] = scan.nextInt(); pre[i] = pre[i - 1] + a[i]; } while (k < n) { for ..