坑在B题是常态,弱智的日常。

是找中位数不是平均值。

慌了,乱写了

出了一塌糊涂的ZZ代码

特记一下

/** @Date    : 2017-08-27 17:25:11
* @FileName: B.cpp
* @Platform: Windows
* @Author : Lweleth (SoungEarlf@gmail.com)
* @Link : https://github.com/
* @Version : $Id$
*/
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int ,int>
#define MP(x, y) make_pair((x),(y))
#define fi first
#define se second
#define PB(x) push_back((x))
#define MMG(x) memset((x), -1,sizeof(x))
#define MMF(x) memset((x),0,sizeof(x))
#define MMI(x) memset((x), INF, sizeof(x))
using namespace std; const int INF = 0x3f3f3f3f;
const int N = 1e5+20;
const double eps = 1e-8; vector<int>q;
int main()
{
int n, k, p, x, y;
while(cin >> n >> k >> p >> x >> y)
{
q.clear();
int rec = 0;
int ma = 0;
int mi = 0;
int cnt1 = 0;
int cnt2 = 0;
int flag = 0;
for(int i = 0; i < k; i++)
{
int t;
scanf("%d", &t);
if(t >= y)
{
if(cnt2 == (n+1)/2)
cnt1++;
else cnt2++;
}
else
{
if(cnt1 == n/2)
cnt2++, flag = 1;
else cnt1++;
}
rec += t;
} if(rec + n/2 - cnt1 + ((n + 1) / 2 - cnt2)*y > x || flag)
{
printf("-1\n");
continue;
}
for(int i = 0; i < (n/2) - cnt1; i++)
rec+=1, q.PB(1);
for(int i = 0; i < (n + 1) / 2 - cnt2; i++)
rec+=y, q.PB(y);
if(rec > x)
{
printf("-1\n");
continue;
}
for(auto i:q)
printf("%d ", i);
printf("\n");
} return 0;
}

CF540 B 贪心的更多相关文章

  1. BZOJ 1692: [Usaco2007 Dec]队列变换 [后缀数组 贪心]

    1692: [Usaco2007 Dec]队列变换 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1383  Solved: 582[Submit][St ...

  2. HDOJ 1051. Wooden Sticks 贪心 结构体排序

    Wooden Sticks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  3. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  4. BZOJ 1691: [Usaco2007 Dec]挑剔的美食家 [treap 贪心]

    1691: [Usaco2007 Dec]挑剔的美食家 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 786  Solved: 391[Submit][S ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【BZOJ-4245】OR-XOR 按位贪心

    4245: [ONTAK2015]OR-XOR Time Limit: 10 Sec  Memory Limit: 256 MBSubmit: 486  Solved: 266[Submit][Sta ...

  7. code vs 1098 均分纸牌(贪心)

    1098 均分纸牌 2002年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题解   题目描述 Description 有 N 堆纸牌 ...

  8. 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心

    SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...

  9. 【贪心】HDU 1257

    HDU 1257 最少拦截系统 题意:中文题不解释. 思路:网上有说贪心有说DP,想法就是开一个数组存每个拦截系统当前最高能拦截的导弹高度.输入每个导弹高度的时候就开始处理,遍历每一个拦截系统,一旦最 ...

随机推荐

  1. 有关rand(),srand()产生随机数学习总结

    看到夏雪冬日的有关rand()和srand()产生随机数的总结,挺好的,学习了,然后又有百度其他人的成果,系统总结一下.本文转自夏雪冬日:http://www.cnblogs.com/heyongga ...

  2. erlang node time ticket

    Erlang doesn't detect net splits by itself. You could start looking atnet_kernel:set_net_ticktime/2 ...

  3. 如何在一台 web 服务器上注册CA证书

    试验环境介绍(CA的主机为192.168.23.10.httpd的主机为:192.168.23.11) 1:新建一台web服务器,主机名为www yum install -y httpd   2:生成 ...

  4. BOM对象属性定时器的调用

    使count中的内容,自动切换 <body> <h1 id="count"></h1> </body> //获取count var ...

  5. nodejs之Buffer

    Buffer是什么? 简单点理解,buff就是固定长度的uint8array.(es6已实现TypedArray). 由于是固定长度所以没有了splice,concat方法. 由于是固定类型所以没有了 ...

  6. PHP中类和对象

    面向对象中的基本概念 类和对象 对象:  万物皆对象: 类: 任何对象,都可以人为“规定”为某种类型(类别): class  Person{ var  $name ; var  $age; var   ...

  7. [OS] 系统调用

  8. ZOJ2725_Digital Deletions

    题意是这样的,一开始给你一串数字,两个人轮流操作,操作可以分为两种. 1.每次修改一个数字,使其变为一个小于当前的非负数. 2.移除中间的某一个0以及0右边的所有数字. 使得所有数字消失的游戏者获胜. ...

  9. 【模考】2018.04.08 Connection

    Description 给定一张N个点M条边的连通无向图,问最少需要断开多少条边使得这张图不再连通. Input 第一行两个整数N,M含义如题所示. 接下来M行,每行两个正整数x,y,表示x和y之间有 ...

  10. 【CF666E】Forensic Examination(后缀自动机,线段树合并)

    [CF666E]Forensic Examination(后缀自动机,线段树合并) 题面 洛谷 CF 翻译: 给定一个串\(S\)和若干个串\(T_i\) 每次询问\(S[pl..pr]\)在\(T_ ...