Problem E. Easy Problemset
Input file: easy.in

Output file: easy.out
Perhaps one of the hardest problems of any ACM ICPC contest is to create a problemset with a reasonable number of easy problems. On Not Easy European Regional Contest this problem is solved as follows. There are n jury members (judges). They are numbered from 1 to n. Judge number i had prepared pi easy problems before the jury meeting. Each of these problems has a hardness between 0 and 49 (the higher the harder). Each judge also knows a very large (say infinite) number of hard problems (their hardness is 50). Judges need to select k problems to be used on the contest during this meeting.

They start to propose problems in the ascending order of judges numbers. The first judge takes the first problem from his list of remaining easy problems (or a hard problem, if he has already proposed all his easy problems) and proposes it. The proposed problem is selected for the contest if its hardness is greater than or equal to the total hardness of the problems selected so far, otherwise it is considered too easy. Then the second judge does the same etc.; after the n-th judge, the first one proposes his next problem, and so on. This procedure is stopped immediately when k problems are selected. If all judges have proposed all their easy problems, but they still have selected less than k problems, then they take some hard problems to complete the problemset regardless of the total hardness. Your task is to calculate the total hardness of the problemset created by the judges.
Input The first line of the input file contains the number of judges n (2 ≤ n ≤ 10) and the number of problems k (8 ≤ k ≤ 14). The i-th of the following n lines contains the description of the problems prepared by the i-th judge. It starts with pi (1 ≤ pi ≤ 10) followed by pi non negative integers between 0 and 49 — the hardnesses of the problems prepared by the i-th judge in the order they will be proposed.
Output Output the only integer — the total hardness of the selected problems.
Sample input and output
3 8

5 0 3 12 1 10

4 1 1 23 20

4 1 5 17 49

94

3 10

2 1 3

1 1

2 2 5

354
In the first example, three problems with hardnesses of 0, 1, and 1 are selected first. Then the first judge proposes the problem with hardness 3 and it is selected, too. The problem proposed by the second judge with hardness 1 is not selected, because it is too easy. Then the problems proposed by the third, the first, and the second judges are selected (their hardnesses are 5, 12 and 23). The following three proposed problems with hardness of 17, 1 and 20 are not selected, and the problemset is completed with a problem proposed by the third judge with hardness of 49. So the total hardness of the problemset is 94.

In the second example, three problems with hardnesses of 1, 1, and 2 are selected first. The second problem of the first judge (hardness 3) is too easy. The second judge is out of his easy problems, so he proposes a problem with hardness 50 and it is selected. The third judge’s problem with hardness 5 is not selected. The judges decide to take 6 more hard problems to complete the problemset, which gives the total hardness of 54 + 6 · 50 = 354.

题意:n行,每行第一个数是pi,代表这一行有pi个数,一共取k个数,竖着取,要求是题目中的黑体字,所选取的数的总和不能超过要选的数,这个要选的数才能被选。

题解:注意数据范围是0到49,没有的时添50,暴力跑,如果竖着选的时候发现没有数就选50,模拟下就行了。

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
freopen("easy.in","r",stdin);
freopen("easy.out","w",stdout);
int data[],a[][],cnt;
int n,k;
while(cin>>n>>k)
{
memset(a,-,sizeof(a));
memset(data,-,sizeof(data));
cnt=;
int maxlen=-;
for(int i=;i<n;i++)
{
cin>>a[i][];
if(a[i][]>maxlen)
maxlen=a[i][];
for(int j=;j<=a[i][];j++)
cin>>a[i][j];
}
for(int j=;j<=maxlen;j++)
{
for(int i=;i<n;i++)
data[cnt++]=a[i][j];
}
// for(int i=0;i<cnt;i++)
// cout<<data[i]<<" ";
int num=;
int sum=;
for(int i=;i<cnt;i++)
{
if(num==k)
break;
if(sum>=)
break;
if(data[i]==-&&sum<=)
break;
if(sum<=data[i])
{
sum+=data[i];
num++;
}
}
if(num<k)
sum=sum+(k-num)*;
cout<<sum<<endl;
}
return ;
}

Gym 100851E Easy Problemset (模拟题)的更多相关文章

  1. Gym 100851E Easy Problemset (水题,模拟)

    题意:给定 n 个裁判,然后每个都一些题目,现在要从每一个按顺序去选出 k 个题,并且这 k 个要按不递减顺序,如果没有,就用50补充. 析:就按他说的来,直接模拟就好. 代码如下: #pragma ...

  2. Gym 100801E Easy Arithmetic (思维题)

    题目:传送门.(需要下载PDF) 题意:给定一个长度不超过1000的字符串表达式,向该表达式中加入'+'或'-',使得表达式的值最大,输出该表达式. 题解:比如300-456就改成300-4+56,遇 ...

  3. Gym 100646 Problem C: LCR 模拟题

    Problem C: LCR 题目连接: http://codeforces.com/gym/100646/attachments Description LCR is a simple game f ...

  4. Codeforces Gym 100269B Ballot Analyzing Device 模拟题

    Ballot Analyzing Device 题目连接: http://codeforces.com/gym/100269/attachments Description Election comm ...

  5. poj1472[模拟题]

    Instant Complexity Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2017   Accepted: 698 ...

  6. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题

    Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...

  7. poj 1008:Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  8. poj 1888 Crossword Answers 模拟题

    Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 D ...

  9. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

随机推荐

  1. 001-编译hadoop-2.5.2总结

    前两天废了很大的劲来对hadoop-2.5.2进行64位系统的手动编译,由于对linux系统环境以及hadoop本身的不熟悉,编译过程中也出现了很多的问题,在此记录一下,对自己以后再次编译和看到此文章 ...

  2. 洛谷P2015 二叉苹果树

    题目描述 有一棵苹果树,如果树枝有分叉,一定是分2叉(就是说没有只有1个儿子的结点) 这棵树共有N个结点(叶子点或者树枝分叉点),编号为1-N,树根编号一定是1. 我们用一根树枝两端连接的结点的编号来 ...

  3. DLUTOJ #1306 Segment Tree?

    Description 有一个N个整数的序列(每个数的初值为0).每个数都是整数.你有M次操作.操作有两种类型: ——Add  Di  Xi 从第一个数开始每隔Di 个位置增加Xi ——Query L ...

  4. Apache配置默认首页

    操作系统:CentOS 6.5 Apache默认主页为index.html,如果要修改为index.php或其它,需要修改httpd.conf文件 用vim或其它编辑器打开httpd.conf 在上图 ...

  5. Max批量导出工具

    Max批量导出工具 http://www.paulneale.com/scripts/batchItMax/batchItMax.htm Scripts Batch It Max: Batch It ...

  6. axel

    Linux下多线程下载工具 - Axel 2011年10月8日 上午 | 作者:VPS侦探 Axel 是 Linux 下一个不错的HTTP/FTP高速下载工具.支持多线程下载.断点续传,且可以从多个地 ...

  7. phpcms 采集教程

    Phpcms网站管理系统目前最新版本为Phpcms v9,作为国内主流CMS系统之一,目前已有数万网站的应用规模.那么其自带的采集模块功能如何呢,来看看吧. 文章采集 Phpcms v9默认内置有文章 ...

  8. include(thinkphp常用内置标签)

    变量输出使用普通标签就足够了,但是要完成其他的控制.循环和判断功能,就需要借助模板引擎的标签库功能了,系统内置标签库的所有标签无需引入标签库即可直接使用. XML标签有两种,包括闭合标签和开放标签,一 ...

  9. SVN 学习笔记

    命令参考 Api手册 清除用户密码 rm ~/.subversion/auth 撤销本地svn操作 svn revert 解决冲突 分支处理 拷贝分支 svn copy http://svn.exam ...

  10. C# 跨线程访问或者设置UI线程控件的方法

    一.背景 在C#中,由于使用线程和调用UI的线程属于两个不同的线程,如果在线程中直接设置UI元素的属性,此时就会出现跨线程错误. 二.问题解决方法 使用控件自带的Invoke或者BeginInvoke ...