Alice, Bob and Chocolate
题目(https://acs.jxnu.edu.cn/problem/CF6C)描述:
Alice and Bob like games. And now they are ready to start a new game. They have placed n chocolate bars in a line. Alice starts to eat chocolate bars one by one from left to right, and Bob — from right to left. For each chocololate bar the time, needed for the player to consume it, is known (Alice and Bob eat them with equal speed). When the player consumes a chocolate bar, he immediately starts with another. It is not allowed to eat two chocolate bars at the same time, to leave the bar unfinished and to make pauses. If both players start to eat the same bar simultaneously, Bob leaves it to Alice as a true gentleman.
How many bars each of the players will consume?
输入:
The first line contains one integer n (1?≤?n?≤?105) — the amount of bars on the table. The second line contains a sequence t1,?t2,?...,?tn (1?≤?ti?≤?1000), where ti is the time (in seconds) needed to consume the i-th bar (in the order from left to right).
输出:
Print two numbers a and b, where a is the amount of bars consumed by Alice, and b is the amount of bars consumed by Bob.
样例输入:
5
2 9 8 2 7
样例输出:
2 3
翻译:
爱丽丝和鲍勃喜欢游戏。现在他们准备开始一个新游戏。他们把n个巧克力杯放成一行。爱丽丝从左向右吃巧克力杯,鲍勃从右向左吃。每个人吃完一个巧克力杯的时间已知(两个人需要的时间相同)。当他们吃完一个巧克力杯立马吃下一个。不允许同时吃两个,或没吃完,或暂停。如果两个人同时开始吃,鲍勃认为爱丽丝是个绅士。
他们两个分别吃掉多少个巧克力杯?
输入:
第一行包含一个整数n(1?≤?n?≤?105)表示巧克力杯的个数。第二行包含一个序列t1,?t2,?...,?tn (1?≤?ti?≤?1000), 表示吃完第i个巧克力杯所需时间(按从左向右的顺序)。
输出:
两个数字a和b,分别表示爱丽丝和鲍勃吃掉的巧克力杯的个数。
样例输入:
5
2 9 8 2 7
样例输出:
2 3