坑在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. 对首师大研究生院的UI分析

    我们分析的是首都师范大学研究生院的UI界面 网站链接http://grad.cnu.edu.cn/index.htm 学校设计和石家庄铁道大学的界面类似,都是有一个大的置顶的名字,将学校或者学院的名字 ...

  2. 人生苦短,我用Python!

    一.程序分析 1.读取文件到缓冲区 def process_file(): # 读文件到缓冲区 try: # 打开文件 f = open("C:\\Users\\panbo\\Desktop ...

  3. POJ 2063 Investment 滚动数组+完全背包

    题目链接: http://poj.org/problem?id=2063 题意: 你现在有现金m元,你要做n年的存款投资,给你k种投资方式,每种需要现金vi元,能获得xi元的理论,一年到期后你要利用拿 ...

  4. lintcode-496-玩具工厂

    496-玩具工厂 工厂模式是一种常见的设计模式.请实现一个玩具工厂 ToyFactory 用来产生不同的玩具类.可以假设只有猫和狗两种玩具. 您在真实的面试中是否遇到过这个题? Yes 样例 ToyF ...

  5. MDL详解

    以下的虚拟内存可以理解成逻辑内存,因为我觉得只有这样才能讲通下面所有的东西.以下的“未分页”指没有为页进行编码. 以下为MDL结构体(我很郁闷,我在MSDN上没有找到这个结构体) typedef st ...

  6. Java第一次笔记

  7. 【Java】对ArrayList排序

    java如何对ArrayList中对象按照该对象某属性排序 (从小到大) 两种方法: 方法一:Comparator<KNNNode> comparator = new Comparator ...

  8. ZOJ 2060 A-Fibonacci Again

    https://vjudge.net/contest/67836#problem/A There are another kind of Fibonacci numbers: F(0) = 7, F( ...

  9. JAVA程序测试时用到的与内存测试有关的东西

    1.JVM启动参数 垃圾回收器调用情况参数,使用如下参数可以看到程序何时启动GC进行垃圾回收,和垃圾回收的详细信息. java Test -XX:+PrintGCDetails -XX:+PrintG ...

  10. Spring事务管理Transaction【转】

    Spring提供了许多内置事务管理器实现(原文链接:https://www.cnblogs.com/qiqiweige/p/5000086.html): DataSourceTransactionMa ...