Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Create an arrayList of North cows, N_cows, and East cows E_cows
- 2. Find the collisions between north and east cows
- array for the amount of grass each cow eats
- loop N times
- int collisionTime = infinity
- int cow1 = -1, cow2 = -1;
- loop through N_cows:
- loop through E_cows:
- if they collide:
- if the collision time is less than collisionTime:
- update collisionTime, cow1, and cow2
- if there is no collision:
- break;
- // We have our collision!
- See if cow1 or cow2 stops
- Update the number of grass that cow eats for the output
- Remove the cow that stops from the arrayList
- // For printing our output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement