第二次组队赛(xiao)codeforces1070

本文包含了四道编程竞赛题目:关于视频是否能均分到帖子中、如何高效处理垃圾、选举辩论赛观众选择策略以最大化影响力,以及BerOS文件系统的建议方案。每道题目提供了详细的理解和解题思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

K. Video Posts

 

Input

The first line contains two integers n and k (1≤k≤n≤105). The next line contains n positive integer numbers a1,a2,…,an (1≤ai≤104), where ai is the duration of the i-th video.

Output

If solution exists, print "Yes" in the first line. Print k positive integers s1,s2,…,sk (s1+s2+⋯+sk=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".

Examples

Input

6 3
3 3 1 4 1 6

Output

Yes
2 3 1 

Input

3 3
1 1 1

Output

Yes
1 1 1 

Input

3 3
1 1 2

Output

No

Input

3 1
1 10 100

Output

Yes
3 

题意:就是看能否均分,是的话就Yes,然后输出可以由几个数组成,不是就No

#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
map<int,int>mp;
map<int,int>::iterator it;
ll c[100010],a[101010];
int main()
{
    ll n,k,i,j,s=0,ss;
    cin>>n>>k;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    if(s%k)
        printf("No\n");
    else
    {
        ss=s/k;
        ll e=0,ans=0,p=0;
        memset(c,0,sizeof(c));
        for(i=0; i<n; i++)
        {
            ans+=a[i];
            p++;
            if(ans==ss)
            {
                c[e++]=p;
                ans=0;
                p=0;
            }
        }
        //cout<<e<<endl;
        if(e==k)
        {
            cout<<"Yes"<<endl;
            cout<<c[0];
            for(i=1; i<e; i++)
                cout<<" "<<c[i];
            cout<<endl;
        }
        else
            cout<<"No"<<endl;
    }

    return 0;
}

D. Garbage Disposal

Examples

Input

3 2
3 2 1

Output

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值