CF66E.Petya and Post

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn . One can fuel the car at the ii -th station with no more than aia_{i} liters of gasoline. Besides, one can fuel the car no more than once at each station. Also, the distance between the 11 -st and the 22 -nd station is b1b_{1} kilometers, the distance between the 22 -nd and the 33 -rd one is b2b_{2} kilometers, ..., between the (n1)(n-1) -th and the nn -th ones the distance is bn1b_{n-1} kilometers and between the nn -th and the 11 -st one the distance is bnb_{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 aia_{i} is equal to the sum of all bib_{i} . The ii -th gas station and ii -th post office are very close, so the distance between them is 00 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.

输入格式

The first line contains integer nn ( 1<=n<=1051<=n<=10^{5} ). The second line contains nn integers aia_{i} — amount of gasoline on the ii -th station. The third line contains nn integers b1,b2,...,bnb_{1},b_{2},...,b_{n} . They are the distances between the 11 -st and the 22 -nd gas stations, between the 22 -nd and the 33 -rd ones, ..., between the nn -th and the 11 -st ones, respectively. The sum of all bib_{i} equals to the sum of all aia_{i} and is no more than 10910^{9} . Each of the numbers aia_{i} , bib_{i} is no less than 11 and no more than 10910^{9} .

输出格式

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

输入输出样例

  • 输入#1

    4
    1 7 2 3
    8 1 1 3
    

    输出#1

    2
    2 4
    
  • 输入#2

    8
    1 2 1 2 1 2 1 2
    2 1 2 1 2 1 2 1
    

    输出#2

    8
    1 2 3 4 5 6 7 8
    
首页