思路:

贪心。

实现:

 #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. 条款一:仔细区别pointers 和 reference

    1.一个reference必须总代表某个对象,没有所谓的null reference.如果你有一个变量,其目的是用来指向(代表)另一个对象,但是也有可能它不指向(代表)另一个对象,那么应该使用poin ...

  2. Samba完整篇 ubuntu 10.04

    基本的服务器准备工作 修改Root密码 sudo passwd root 在提示下建立新密码 修改静态IP: sudo gedit /etc/network/interfaces   #网络配置文件 ...

  3. poj 2728 最优比例生成树(01分数规划)模板

    /* 迭代法 :204Ms */ #include<stdio.h> #include<string.h> #include<math.h> #define N 1 ...

  4. android studio 0.8.1使用和遇到问题解决

    谷歌6月底公布了五大系统,而且android studio同步升级到了android studio 0.8.1.升级了的android studio确实有一些新的变化.执行速度变快,而且还能够选择开发 ...

  5. Python3.4 12306 2015年3月验证码识别

    import ssl import json from PIL import Image import requests import re import urllib.request as urll ...

  6. eclipse android开发,文本编辑xml文件,给控件添加ID后,R.java,不自动的问题。

    直接编辑xml文件给控件添加id,不自动更新.原来的id写法:@id/et_tel 然后改写成这样:@+id/et_tel  然后就好了!操`1

  7. android 3G移植【转】

    本文转载自:http://blog.csdn.net/hanmengaidudu/article/details/17028383 一 开发环境简介 内容 说明 3G模块 华为EM820W(WCDMA ...

  8. 一位ACMer过来人的心得(转)

    刻苦的训练我打算最后稍微提一下.主要说后者:什么是有效地训练? 我想说下我的理解.很多ACMer入门的时候,都被告知:要多做题,做个500多道就变牛了.其实,这既不是充分条件.也不会是必要条件. 我觉 ...

  9. eclipse导出签名apk的混淆设置

    1.设置project.properties文件: 2.设置proguard-project.txt文件:

  10. luogu 3388 【模板】割点(割顶)

    点双. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> ...