CF250A.Paper Work

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as nn days. Right now his task is to make a series of reports about the company's performance for the last nn days. We know that the main information in a day report is value aia_{i} , the company's profit on the ii -th day. If aia_{i} is negative, then the company suffered losses on the ii -th day.

Polycarpus should sort the daily reports into folders. Each folder should include data on the company's performance for several consecutive days. Of course, the information on each of the nn days should be exactly in one folder. Thus, Polycarpus puts information on the first few days in the first folder. The information on the several following days goes to the second folder, and so on.

It is known that the boss reads one daily report folder per day. If one folder has three or more reports for the days in which the company suffered losses (a_{i}<0) , he loses his temper and his wrath is terrible.

Therefore, Polycarpus wants to prepare the folders so that none of them contains information on three or more days with the loss, and the number of folders is minimal.

Write a program that, given sequence aia_{i} , will print the minimum number of folders.

输入格式

The first line contains integer nn ( 1<=n<=1001<=n<=100 ), nn is the number of days. The second line contains a sequence of integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( ai<=100|a_{i}|<=100 ), where aia_{i} means the company profit on the ii -th day. It is possible that the company has no days with the negative aia_{i} .

输出格式

Print an integer kk — the required minimum number of folders. In the second line print a sequence of integers b1b_{1} , b2b_{2} , ..., bkb_{k} , where bjb_{j} is the number of day reports in the jj -th folder.

If there are multiple ways to sort the reports into kk days, print any of them.

输入输出样例

  • 输入#1

    11
    1 2 3 -4 -5 -6 5 -5 -6 -7 6
    

    输出#1

    3
    5 3 3 
  • 输入#2

    5
    0 -1 100 -1 0
    

    输出#2

    1
    5 

说明/提示

Here goes a way to sort the reports from the first sample into three folders:

1 2 3 -4 -5 | -6 5 -5 | -6 -7 6In the second sample you can put all five reports in one folder.

首页