• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #216 Div2 B

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

Valera loves to participate in competitions. Especially in programming contests. Today he has participated in the contest with his team, consisting of n students (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 least l points and at most r points;
  • in total, all members of the team scored exactly sall points;
  • the total score of the k members of the team who scored the most points is equal to exactly sk; more formally, if a1, a2, ..., an is the sequence of points earned by the team of students in the non-increasing order (a1 ≥ a2 ≥ ... ≥ an), then sk = a1 + a2 + ... + ak.

 

However, Valera did not find out exactly how many points each of n students 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 integers n, 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 exactly n integers a1, 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 
 1 #include <cstdio>
 2 #include <iostream>
 3 #include <vector>
 4 #include <set>
 5 #include <cstring>
 6 #include <string>
 7 #include <map>
 8 #include <cmath>
 9 #include <ctime>
10 #include <algorithm>
11 #include <queue>
12 
13 using namespace std;
14 #define INF 0x7fffffff
15 #define maxm 1001
16 #define mod 1000000007
17 #define mp make_pair
18 #define pb push_back
19 #define rep(i,n) for(int i = 0; i < (n); i++)
20 #define re return
21 #define fi first
22 #define se second
23 #define sz(x) ((int) (x).size())
24 #define all(x) (x).begin(), (x).end()
25 #define sqr(x) ((x) * (x))
26 #define sqrt(x) sqrt(abs(x))
27 #define y0 y3487465
28 #define y1 y8687969
29 #define fill(x,y) memset(x,y,sizeof(x))
30 
31 typedef vector<int> vi;
32 typedef long long ll;
33 typedef long double ld;
34 typedef double D;
35 typedef pair<int, int> ii;
36 typedef vector<ii> vii;
37 typedef vector<string> vs;
38 typedef vector<vi> vvi;
39 
40 template<class T> T abs(T x) { re x > 0 ? x : -x; }
41 
42 const int maxn = 100015;
43 
44 int n, m, t, k, x, l, r, s, sk;
45 int a[maxn], b[maxn];
46 
47 int main(){
48     scanf("%d%d%d%d%d%d", &n, &k, &l, &r, &s, &sk);
49     int ans = s / n;
50     t = s - (ans*n);
51     for (int i = 0; i < n; i++)a[i] = ans;
52     for (int i = 0; i < t; i++)a[i]++;
53     int sum = 0;
54     for (int i = 0; i < k; i++)sum += a[i];
55     if (sum != sk){
56         sum = sk - sum;
57         t = sum / k;
58         for (int i = 0; i < k; i++)a[i] += t;
59         t = sum - t*k;
60         for (int i = k - 1; i >= k - t; i--)a[i]++;
61         t = sum / (n - k);
62         for (int i = k; i < n; i++)a[i] -= t;
63         t = sum - t*(n - k);
64         for (int i = k; i < k+t; i++)a[i]--;
65     }
66     for (int i = 0; i < n; i++)printf("%d ", a[i]);
67     return 0;
68 }
View Code
posted @ 2013-11-30 12:26  HaibaraAi  阅读(124)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3