From 6cd3aca9a0cc174013451f628be87e1717a4f65d Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Sat, 18 Apr 2026 13:33:08 -0500 Subject: [PATCH] solved dealem out, not weight diff --- .../battle-of-the-brains-2026/DealEmOut.java | 35 ++++++++++++++++ .../battle-of-the-brains-2026/Solution.java | 5 +-- .../WeightedDifference.java | 40 +++++++++++++++++++ 3 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 solutions/battle-of-the-brains-2026/DealEmOut.java create mode 100644 solutions/battle-of-the-brains-2026/WeightedDifference.java diff --git a/solutions/battle-of-the-brains-2026/DealEmOut.java b/solutions/battle-of-the-brains-2026/DealEmOut.java new file mode 100644 index 0000000..c171204 --- /dev/null +++ b/solutions/battle-of-the-brains-2026/DealEmOut.java @@ -0,0 +1,35 @@ +// General imports + +import java.util.Scanner; + +public class DealEmOut { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + // Write code here + + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + + int cards = 0; + int value = a + b + c; + + if (a == 0) + cards++; + if (b == 0) + cards++; + if (c == 0) + cards++; + + int known = 3 - cards; + + double adder = (416.0 - value) / (52.0 - known); + + double returner = value + adder * cards; + + System.out.printf("%.2f", returner); + + sc.close(); + } +} diff --git a/solutions/battle-of-the-brains-2026/Solution.java b/solutions/battle-of-the-brains-2026/Solution.java index df0844a..402443e 100644 --- a/solutions/battle-of-the-brains-2026/Solution.java +++ b/solutions/battle-of-the-brains-2026/Solution.java @@ -1,8 +1,6 @@ // General imports -import java.io.*; -import java.math.*; -import java.util.*; +import java.util.Scanner; public class Solution { public static void main(String[] args) { @@ -16,3 +14,4 @@ public class Solution { sc.close(); } } + diff --git a/solutions/battle-of-the-brains-2026/WeightedDifference.java b/solutions/battle-of-the-brains-2026/WeightedDifference.java new file mode 100644 index 0000000..6c0cf7f --- /dev/null +++ b/solutions/battle-of-the-brains-2026/WeightedDifference.java @@ -0,0 +1,40 @@ +// General imports + +import java.util.Scanner; + +public class WeightedDifference { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + // Write code here + + int a = sc.nextInt(); + int[] ar = new int[a]; + for (int i = 0; i < a; i++) { + ar[i] = sc.nextInt(); + } + + long max = Long.MIN_VALUE; + int left = 0; + int right = ar.length - 1; + int gap = right - left; + int prevGap = 0; + while (gap > 0) { + int diff = ar[right] - ar[left] - (right - left); + max = diff > max ? diff : max; + if (gap == prevGap && right < ar.length - 1) { + left++; + right++; + } else { + gap--; + prevGap = gap; + left = 0; + right = gap; + } + } + + System.out.println(max); + sc.close(); + } + +}