`
369540808
  • 浏览: 196326 次
文章分类
社区版块
存档分类
最新评论

CodeForces 369B Valera and Contest

 
阅读更多


B. Valera and Contest
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting ofnstudents (including Valera). This contest was an individual competition, so each student in the team solved problems individually.

After the contest was over, Valera was interested in results. He found out that:

  • each student in the team scored at leastlpoints and at mostrpoints;
  • in total, all members of the team scored exactlysallpoints;
  • the total score of thekmembers of the team who scored the most points is equal to exactlysk; more formally, ifa1, a2, ..., anis the sequence of points earned by the team of students in the non-increasing order(a1 ≥ a2 ≥ ... ≥ an), thensk = a1 + a2 + ... + ak.

However, Valera did not find out exactly how many points each ofnstudents scored. Valera asked you to recover any distribution of scores between the students of the team, such that all the conditions above are met.

Input

The first line of the input contains exactly six integersn, k, l, r, sall, sk(1 ≤ n, k, l, r ≤ 1000;l ≤ r;k ≤ n;1 ≤ sk ≤ sall ≤ 106).

It's guaranteed that the input is such that the answer exists.

Output

Print exactlynintegersa1, a2, ..., an— the number of points each student scored. If there are multiple solutions, you can print any of them. You can print the distribution of points in any order.

Sample test(s)
input
5 3 1 3 13 9
output
2 3 2 3 3 
input
5 3 1 3 15 9
output
3 3 3 3 3 


一定要注意 n==k 不然会RE的

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

const int maxn=1100;

int  sorce[maxn],n,k,l,r,sall,sk;

int main()
{
    cin>>n>>k>>l>>r>>sall>>sk;
    for(int i=1;i<=k;i++)
    {
        sorce[i]=sk/k;
    }
    int t=sk%k,i=1;
    while(t)
    {
        t--; sorce[i++]++;
    }
    if(k!=n)
    {
        for(int i=k+1;i<=n;i++)
        {
            sorce[i]=(sall-sk)/(n-k);
        }
        int t,i;
        t=(sall-sk)%(n-k),i=k+1;
        while(t)
        {
            t--; sorce[i++]++;
        }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<sorce[i]<<" ";
    }
    return 0;
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics