Distributing Candies
시간 제한: 4000ms메모리 제한: 2048MB출처: IOI 2021BOJ 22023
문제
Aunty Khong is preparing boxes of candies for students from a nearby school. The boxes are numbered from to and are initially empty. Box () has a capacity of candies.
Aunty Khong spends days preparing the boxes. On day (), she performs an action specified by three integers , and where and . For each box satisfying :
- If , Aunty Khong adds candies to box , one by one, until she has added exactly candies or the box becomes full. In other words, if the box had candies before the action, it will have candies after the action.
- If , Aunty Khong removes candies from box , one by one, until she has removed exactly candies or the box becomes empty. In other words, if the box had candies before the action, it will have candies after the action.
Your task is to determine the number of candies in each box after the days.
코드를 제출하려면 로그인하세요.