思路:

贪心。

实现:

 #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std; int n, p, k, x, y;
vector<int> a;
int main()
{
cin >> n >> k >> p >> x >> y;
int sum = , tmp = ;
for (int i = ; i < k; i++)
{
cin >> tmp;
a.push_back(tmp);
sum += a[i];
}
if (x - sum < n - k)
{
puts("-1");
}
else
{
bool flag = true;
vector<int> res;
sort(a.begin(), a.begin() + k);
int now = k;
sum = x - sum;
while (now < n)
{
int pos = lower_bound(a.begin(), a.begin() + now, y) - a.begin();
if (pos < now / )
{
a.insert(a.begin(), );
res.push_back();
sum--;
}
else
{
a.insert(a.begin() + pos, y);
res.push_back(y);
sum -= y;
}
if (sum < )
{
puts("-1");
flag = false;
break;
}
now++;
}
if (flag)
{
if (a[n >> ] >= y)
{
for (int i = ; i < n - k; i++)
{
cout << res[i] << " ";
}
puts("");
}
else
{
puts("-1");
}
}
}
return ;
}

CF540B School Marks的更多相关文章

  1. 【BZOJ-2400】Spoj839Optimal Marks 最小割 + DFS

    2400: Spoj 839 Optimal Marks Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 567  Solved: 202[Submit ...

  2. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  3. 839. Optimal Marks - SPOJ

    You are given an undirected graph G(V, E). Each vertex has a mark which is an integer from the range ...

  4. (CodeForces )540B School Marks 贪心 (中位数)

    Little Vova studies programming to p. Vova is very smart and he can write every test for any mark, b ...

  5. 图论(网络流):SPOJ OPTM - Optimal Marks

    OPTM - Optimal Marks You are given an undirected graph G(V, E). Each vertex has a mark which is an i ...

  6. CodeForces 540B School Marks(思维)

    B. School Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  7. 【SPOJ839】Optimal Marks 网络流

    You are given an undirected graph G(V, E). Each vertex has a mark which is an integer from the range ...

  8. The table name must be enclosed in double quotation marks or sqare bracket while accessing EXCEL by

      1  Preface DB Query Analyzer is presented by Master Gen feng, Ma from Chinese Mainland. It has Eng ...

  9. Codeforces831C Jury Marks

    C. Jury Marks time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

随机推荐

  1. JSP点击计数器

    以下内容引用自http://wiki.jikexueyuan.com/project/jsp/hits-counter.html: 一个点击计数器能得知关于网站某个特定页面的访问量.假设人们第一次登陆 ...

  2. MongoDB小结04 - update【$inc】

    update方法很强大,它有两个参数,一是查询文档,用来找出需要更新的文档,另一个是修改器(modifier)文档,描述对找到的文档做哪些修改. 亮点 更新操作是原子的,若两个更新同时发生,先到达服务 ...

  3. PowerDesinger15设置字体大小

    使用PowerDesigner时,它默认table的字体大小颜色等很难看: 假设通过 Symbol ---> Format进行设置.仅仅能对选中的最改动,新建的Table无效. 能够通过例如以下 ...

  4. redux 存值 及 取值 的操作

    项目目录 首先,一个基于React + Redux + React-Router的项目目录可以按照我下方的图片来构建: 其中assets目录用于存放项目的静态资源,如css/图片等,src目录则用于存 ...

  5. web网站架构演变过程

    我们以javaweb为例,来搭建一个简单的电商系统,看看这个系统可以如何一步步演变.   该系统具备的功能:   用户模块:用户注册和管理 商品模块:商品展示和管理 交易模块:创建交易和管理 阶段一. ...

  6. mysql查看所有存储过程,函数,视图,触发器,表

    查询数据库中的存储过程和函数 方法一: select `name` from mysql.proc where db = 'your_db_name' and `type` = 'PROCEDURE' ...

  7. 为什么有些信号线串接33R小电阻?

    本人只是刚入坑的硬件助理,一名小白,很多都知识不懂,以下信息多数来自网络,可能不准确,恳请批评指正! 正文: 参考资料:http://blog.csdn.net/xiangyuqxq/article/ ...

  8. 图像处理之基础---滤波器之高斯低通滤波器3c代码实现yuv,rgb

    ()高斯理论简介 () ()代码实现 四 使用高斯滤波器进行图像的平滑 ()高斯简介 http://research.microsoft.com/en-us/um/people/kahe/eccv10 ...

  9. Android 获取手机SIM卡运营商

    直接上代码: /** * 获取SIM卡运营商 * * @param context * @return */ public static String getOperators(Context con ...

  10. 【跟我一步一步学Struts2】——登陆样例

    本篇博客通过一个简单的登陆小样例来入门,简单了解一下struts2是怎样工作的: 第一步引入Jar包: commons-fileupload-1.2.1.jar,文件上传 commons-loggin ...