# Problem Description
This is a particle physics simulation problem where particles with initial energy levels must pass through multiple energy boundaries. Each time a particle crosses a boundary, it loses energy equal to half of that boundary's energy value. A particle can only continue if its remaining energy is greater than 0. The goal is to count how many particles successfully pass through all boundaries.

# Visual Facts
1. Example 1 shows:
   - Initial particles PE₁: [49, 35, 21]
   - Two boundaries: BE₁=60, BE₂=10
   - Final remaining particles energy: 14 (1 particle)

2. Example 2 shows:
   - Initial particles PE₁: [59, 65, 21, 87, 92]
   - Three boundaries: BE₁=20, BE₂=80, BE₃=60
   - Final remaining particles energy: [7, 12] (2 particles)

3. At each boundary, the formula PE_next = PE_current - BE/2 is applied

4. The arrows indicate particle progression through boundaries

# Visual Patterns
1. Energy Reduction Pattern:
   - At each boundary, particle energy is reduced by BE/2
   - Example 1: First boundary reduces by 60/2 = 30
   - Example 2: First boundary reduces by 20/2 = 10

2. Elimination Pattern:
   - Particles are eliminated if their energy becomes ≤ 0
   - In Example 1, only particles with sufficient energy progress
   - In Example 2, some particles are eliminated at BE₂ (80/2 = 40 reduction)

3. Success Criteria:
   - A particle must maintain positive energy after all boundary crossings
   - The final energy must be > 0 to be counted
   - The count of remaining particles > 0 is the return value

4. Mathematical Rules:
   - For a particle P to pass boundary B: P - B/2 > 0
   - This must be true for all boundaries in sequence
   - The energy reduction is cumulative across boundaries
   - Formula for final energy: PE_final = PE_initial - Σ(BE_i/2) for all boundaries i


# Solution
from typing import List

def solution(particle_energy: List[int], energy_boundary: List[int]) -> int:
    """
    Calculates the number of particles that can pass through all energy boundaries.

    Args:
        particle_energy: A list of energy levels for each particle
        energy_boundary: A list of energy levels for each boundary

    Returns:
        The number of particles that successfully pass through all energy boundaries
    """
    sum_of_bounary = sum(energy_boundary) * 0.5
    count = 0 
    for i in particle_energy:
        if i > sum_of_bounary:
            count += 1
    return count


# Test Script
def test():
    test_cases = [
        ([59,65,21,87,92],[20,80,40], 2),
        ([49,25,21],[60, 10], 1),
        ([76, 354, 106, 564, 905], [70, 20, 60, 90, 50, 80], 3),
        ([576, 26, 939, 480, 196, 709], [60, 30, 90, 30, 20, 40, 30, 40, 60, 30], 4),
        ([475, 507, 343, 33, 191, 14, 190, 472, 568], [40, 90, 60, 80, 30, 20], 7),
        ([543, 281, 244, 460, 750], [30, 10, 30, 100], 5),
        ([268, 345, 774, 490, 983, 125, 728, 766, 437, 901], [50, 10, 90, 100, 50, 10, 20], 9),
        ([389, 694, 197, 563, 571, 415], [30, 10, 90, 90, 60], 6),
        ([147, 246, 718, 454, 448], [70, 20, 40, 90, 50, 100, 40], 4),
        ([94, 497, 726, 395, 203, 654], [100, 40, 10, 40, 70], 5)
        
    ]

    for particle_energy, energy_boundary, expected_output in test_cases:
        try:
            output = solution(particle_energy, energy_boundary)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`particle_energy`: {particle_energy}\n"
                f"`energy_boundary`: {energy_boundary}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

        if output != expected_output:
            error_message = (
                f"The following Test Case failed:\n"
                f"`particle_energy`: {particle_energy}\n" 
                f"`energy_boundary`: {energy_boundary}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()