You're not signed in!
Sign in to save your progress and sync your settings across devices.
Authors: Darren Yao, Allen Li
Directly simulating the problem statement, which many Bronze problems allow you to do.
Since there's no formal algorithm involved, the intent of the problem is to assess competence with one's programming language of choice and knowledge of built-in data structures. At least in USACO Bronze, when a problem statement says to find the end result of some process, or to find when something occurs, it's usually sufficient to simulate the process naively.
Alice and Bob are standing on a 2D plane. Alice starts at the point , and Bob starts at the point (). Every second, Alice moves units to the right, and units up. Every second, Bob moves units to the left, and units down. (). Determine if Alice and Bob will ever meet (be at the same point at the same time), and if so, when.
The first line of the input contains and .
The second line of the input contains , , , and .
Please output a single integer containing the number of seconds after the start at which Alice and Bob meet. If they never meet, please output .
There are buckets (), each with a certain capacity (). One day, after a rainstorm, each bucket is filled with units of water (). Charlie then performs the following process: he pours bucket into bucket , then bucket into bucket , and so on, up until pouring bucket into bucket . When Charlie pours bucket into bucket , he pours as much as possible until bucket is empty or bucket is full. Find out how much water is in each bucket once Charlie is done pouring.
The first line of the input contains .
The second line of the input contains the capacities of the buckets, .
The third line of the input contains the amount of water in each bucket .
Please print one line of output, containing space-separated integers: the final amount of water in each bucket once Charlie is done pouring.