Codeforces Beta Round 61 (Div. 2)
E
Petya and Post
Codeforces
2000
原题
← D→
翻译中…

Little Vasya's uncle is a postman. The post offices are located on one circular road. Besides, each post office has its own gas station located next to it. Petya's uncle works as follows: in the morning he should leave the house and go to some post office. In the office he receives a portion of letters and a car. Then he must drive in the given car exactly one round along the circular road and return to the starting post office (the uncle can drive along the circle in any direction, counterclockwise or clockwise). Besides, since the car belongs to the city post, it should also be fuelled with gasoline only at the Post Office stations.

翻译中…

The total number of stations equals to $*n*$. One can fuel the car at the $*i*$-th station with no more than $*a*_{*i*}$ liters of gasoline. Besides, one can fuel the car no more than once at each station. Also, the distance between the $1$-st and the $2$-nd station is $*b*_{1}$ kilometers, the distance between the $2$-nd and the $3$-rd one is $*b*_{2}$ kilometers, ..., between the $(*n* - 1)$-th and the $*n*$-th ones the distance is $*b*_{*n* - 1}$ kilometers and between the $*n*$-th and the $1$-st one the distance is $*b*_{*n*}$ kilometers. Petya's uncle's high-tech car uses only one liter of gasoline per kilometer. It is known that the stations are located so that the sum of all $*a*_{*i*}$ is equal to the sum of all $*b*_{*i*}$. The $*i*$-th gas station and $*i*$-th post office are very close, so the distance between them is $0$ kilometers.

翻译中…

Thus, it becomes clear that if we start from some post offices, then it is not always possible to drive one round along a circular road. The uncle faces the following problem: to what stations can he go in the morning to be able to ride exactly one circle along the circular road and visit all the post offices that are on it?

翻译中…

Petya, who used to attend programming classes, has volunteered to help his uncle, but his knowledge turned out to be not enough, so he asks you to help him write the program that will solve the posed problem.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$). The second line contains $*n*$ integers $*a*_{*i*}$ — amount of gasoline on the $*i*$-th station. The third line contains $*n*$ integers $*b*_{1}, *b*_{2}, ..., *b*_{*n*}$. They are the distances between the $1$-st and the $2$-nd gas stations, between the $2$-nd and the $3$-rd ones, ..., between the $*n*$-th and the $1$-st ones, respectively. The sum of all $*b*_{*i*}$ equals to the sum of all $*a*_{*i*}$ and is no more than $10^{9}$. Each of the numbers $*a*_{*i*}$, $*b*_{*i*}$ is no less than $1$ and no more than $10^{9}$.

翻译中…

Output

翻译中…

Print on the first line the number $*k*$ — the number of possible post offices, from which the car can drive one circle along a circular road. Print on the second line $*k*$ numbers in the ascending order — the numbers of offices, from which the car can start.

翻译中…

样例

Input #1
4
1 7 2 3
8 1 1 3
Output #1
2
2 4
InputCopy OutputCopy
Input #2
8
1 2 1 2 1 2 1 2
2 1 2 1 2 1 2 1
Output #2
8
1 2 3 4 5 6 7 8
InputCopy OutputCopy
题目信息
题号
66E
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。