码迷,mamicode.com
首页 > 其他好文 > 详细

「日常训练」School Marks(Codeforces Round 301 Div.2 B)

时间:2018-09-30 00:01:03      阅读:257      评论:0      收藏:0      [点我收藏+]

标签:ack   return   end   题意   cst   size   iostream   string   cond   

题意与分析(CodeForces 540B)

代码

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define ZERO(x) memset((x), 0, sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define QUICKIO                      ios::sync_with_stdio(false);     cin.tie(0);                      cout.tie(0);
using namespace std;

int main()
{
    int n,k,p,x,y; cin>>n>>k>>p>>x>>y;
    int nowtot=0,belowycnt=0;
    int arr[1005]; rep(i,1,k) { cin>>arr[i]; nowtot+=arr[i]; if(arr[i]<y) belowycnt++; }
    int restmark=x-nowtot;
    if(nowtot+n-k>x || belowycnt>n/2) cout<<-1<<endl;
    else
    {
        int geycnt=k-belowycnt;
        vector<int> vec;
        rep(i,k+1,n)
        {
            if(belowycnt<n/2)
            {
                restmark--;
                if(restmark>=0)
                    { vec.PB(1); belowycnt++; }
            }
            else
            {
                restmark-=y;
                if(restmark>=0)
                    vec.PB(y);
            }
            if(restmark<=0) break;
        }
        if(vec.size()==n-k)
        {
            for(auto it:vec) cout<<it<<" ";
            cout<<endl;
        }
        else cout<<-1<<endl;
    }

    
    return 0;
}

「日常训练」School Marks(Codeforces Round 301 Div.2 B)

标签:ack   return   end   题意   cst   size   iostream   string   cond   

原文地址:https://www.cnblogs.com/samhx/p/cfr301d2b.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!