CF250A.Paper Work
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarpus has been working in the analytic department of the "F.R.A.U.D." company for as much as n days. Right now his task is to make a series of reports about the company's performance for the last n days. We know that the main information in a day report is value a__i, the company's profit on the i-th day. If a__i is negative, then the company suffered losses on the i-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 n 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 a__i, will print the minimum number of folders.
波利卡普斯已在“F.R.A.U.D.”公司的分析部门工作了整整 n 天。目前,他的任务是为最近 n 天的公司业绩制作一系列报告。我们知道,每日报告中的核心信息是数值 ai,即公司在第 i 天的盈利。若 ai 为负,则表示公司在第 i 天亏损。
波利卡普斯需将这些每日报告归档到若干文件夹中。每个文件夹应包含公司连续若干天的业绩数据。显然,全部 n 天的信息必须恰好各自归属且仅归属一个文件夹。因此,波利卡普斯将前若干天的信息放入第一个文件夹,随后若干天的信息放入第二个文件夹,依此类推。
已知老板每天阅读一个文件夹中的所有日报。若某文件夹中包含 三天或以上 的亏损日报告(即满足 ai<0 的天数 ≥3),老板便会大发雷霆,后果极其严重。
因此,波利卡普斯希望以如下方式准备文件夹:任意文件夹中均不包含三天或以上的亏损日报告,且文件夹总数尽可能少。
请编写一个程序,对给定的序列 ai,输出所需的最少文件夹数量。
输入格式
The first line contains integer n (1 ≤ n ≤ 100), n is the number of days. The second line contains a sequence of integers _a_1, _a_2, ..., a__n (|a__i| ≤ 100), where a__i means the company profit on the i-th day. It is possible that the company has no days with the negative a__i.
第一行包含一个整数 n(1≤n≤100),n 表示天数。
第二行包含一个整数序列 a1,a2,…,an(∣ai∣≤100),其中 ai 表示公司在第 i 天的利润。
可能存在所有 ai 均为非负数的情况。
输出格式
Print an integer k — the required minimum number of folders. In the second line print a sequence of integers _b_1, _b_2, ..., b__k, where b__j is the number of day reports in the j-th folder.
If there are multiple ways to sort the reports into k days, print any of them.
输出一个整数 k —— 所需的最少文件夹数量。
第二行输出一个整数序列 b1,b2,…,bk,其中 bj 表示第 j 个文件夹中所含的日报数量。
如果存在多种将日报分配到 k 个文件夹中的方案,请输出任意一种即可。
输入输出样例
输入#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 6
In the second sample you can put all five reports in one folder.
以下是将第一个样例中的报告分为三个文件夹的一种方法:
1 2 3 -4 -5 | -6 5 -5 | -6 -7 6
在第二个样例中,你可以将全部五份报告放入同一个文件夹。
输入解题思路,AI测评打分。不知道怎么写?