A12240 | Video Posts
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarp took $n$ videos, the duration of the $i$ -th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$ -st video is the earliest, the $2$ -nd video is the next, ..., the $n$ -th video is the last.
Now Polycarp wants to publish exactly $k$ ( $1 \le k \le n$ ) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the $j$ -th post is $s_j$ then:
- $s_1+s_2+\dots+s_k=n$ ( $s_i>0$ ),
- the first post contains the videos: $1, 2, \dots, s_1$ ;
- the second post contains the videos: $s_1+1, s_1+2, \dots, s_1+s_2$ ;
- the third post contains the videos: $s_1+s_2+1, s_1+s_2+2, \dots, s_1+s_2+s_3$ ;
- ...
- the $k$ -th post contains videos: $n-s_k+1,n-s_k+2,\dots,n$ .
Polycarp is a perfectionist, he wants the total duration of videos in each post to be the same.
Help Polycarp to find such positive integer values $s_1, s_2, \dots, s_k$ that satisfy all the conditions above.
Now Polycarp wants to publish exactly $k$ ( $1 \le k \le n$ ) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that the first post should contain one or more of the earliest videos, the second post should contain a block (one or more videos) going next and so on. In other words, if the number of videos in the $j$ -th post is $s_j$ then:
- $s_1+s_2+\dots+s_k=n$ ( $s_i>0$ ),
- the first post contains the videos: $1, 2, \dots, s_1$ ;
- the second post contains the videos: $s_1+1, s_1+2, \dots, s_1+s_2$ ;
- the third post contains the videos: $s_1+s_2+1, s_1+s_2+2, \dots, s_1+s_2+s_3$ ;
- ...
- the $k$ -th post contains videos: $n-s_k+1,n-s_k+2,\dots,n$ .
Polycarp is a perfectionist, he wants the total duration of videos in each post to be the same.
Help Polycarp to find such positive integer values $s_1, s_2, \dots, s_k$ that satisfy all the conditions above.
输入格式
The first line contains two integers $n$ and $k$ ( $1 \le k \le n \le 10^5$ ). The next line contains $n$ positive integer numbers $a_1, a_2, \dots, a_n$ ( $1 \le a_i \le 10^4$ ), where $a_i$ is the duration of the $i$ -th video.
输出格式
If solution exists, print "Yes" in the first line. Print $k$ positive integers $s_1, s_2, \dots, s_k$ ( $s_1+s_2+\dots+s_k=n$ ) in the second line. The total duration of videos in each post should be the same. It can be easily proven that the answer is unique (if it exists).
If there is no solution, print a single line "No".
If there is no solution, print a single line "No".
输入输出样例
输入 #1
6 3 3 3 1 4 1 6
输出 #1
Yes 2 3 1
输入 #2
3 3 1 1 1
输出 #2
Yes 1 1 1
输入 #3
3 3 1 1 2
输出 #3
No
输入 #4
3 1 1 10 100
输出 #4
Yes 3
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted