from typing import Dict
from typing import List
from typing import Tuple
import statistics


def get_second_averages(
    elapsed_seconds_average_rewards: Dict[int, List[float]]
) -> Tuple[List[int], List[float]]:
    """
    Get second-averages of rewards.

    :param elapsed_seconds_average_rewards: Elapsed seconds and their average rewards.
    :return: 2-tuple of (1) second values and (2) reward averages.
    """

    seconds = list(sorted(elapsed_seconds_average_rewards.keys()))
    averages = [
        statistics.mean(elapsed_seconds_average_rewards[s])
        for s in seconds
    ]

    return (
        seconds,
        averages
    )