【CF Edu 28 B. Math Show】
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Polycarp takes part in a math show. He is given n tasks, each consists of k subtasks, numbered 1 through k. It takes him tj minutes to solve the j-th subtask of any task. Thus, time required to solve a subtask depends only on its index, but not on the task itself. Polycarp can solve subtasks in any order.
By solving subtask of arbitrary problem he earns one point. Thus, the number of points for task is equal to the number of solved subtasks in it. Moreover, if Polycarp completely solves the task (solves all k of its subtasks), he recieves one extra point. Thus, total number of points he recieves for the complete solution of the task is k + 1.
Polycarp has M minutes of time. What is the maximum number of points he can earn?
Input
The first line contains three integer numbers n, k and M (1 ≤ n ≤ 45, 1 ≤ k ≤ 45, 0 ≤ M ≤ 2·109).
The second line contains k integer numbers, values tj (1 ≤ tj ≤ 1000000), where tj is the time in minutes required to solve j-th subtask of any task.
Output
Print the maximum amount of points Polycarp can earn in M minutes.
Examples
input
3 4 11
1 2 3 4
output
6
input
5 5 10
1 2 4 8 16
output
7
Note
In the first example Polycarp can complete the first task and spend 1 + 2 + 3 + 4 = 10 minutes. He also has the time to solve one subtask of the second task in one minute.
In the second example Polycarp can solve the first subtask of all five tasks and spend 5·1 = 5 minutes. Also he can solve the second subtasks of two tasks and spend 2·2 = 4 minutes. Thus, he earns 5 + 2 = 7 points in total.
【翻译】有n个一样的套题,每套题包含k个题,每个题的解决时间ai可能不同(输入)。做一道题得到1分,做完一套题另外加一分,询问m时间内最多得到多少分。
题解:
①直接贪心写很麻烦,但是观察到对于一套题只有两种状态:做完,没做完。
②由于每套题是完全相同的,所以暴力枚举做完了的套题数,剩下的没做完就排序贪心完成。
#include<stdio.h>
#define S(x,y) (x^=y^=x^=y)
#define go(i,a,b) for(int i=a;i<=b;i++)
int n,k,a[50];long long Time,sum,Score,ans,m;
int main()
{
scanf("%d%d%d",&n,&k,&m);
go(i,1,k)scanf("%d",a+i),sum+=a[i];
go(i,1,k)go(j,i,k)if(a[i]>a[j])S(a[i],a[j]); go(i,0,n){Score=(k+1)*i;if((Time=sum*i)>m)break;
go(j,1,k)Time+(n-i)*a[j]>=m?Score+=(m-Time)/a[j],j=k:(Time+=(n-i)*a[j],Score+=n-i);
Score>ans?ans=Score:1;}printf("%I64d\n",ans);return 0;
}//Paul_Guderian
天空升起紫色的烟花,眼前是一片辉煌
我迎着风向前狂奔,这速度远不能抛开忧伤。————汪峰《十二月的泪》
【CF Edu 28 B. Math Show】的更多相关文章
- 【CF Edu 28 C. Four Segments】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Edu 28 A. Curriculum Vitae】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【2020.11.28提高组模拟】T1染色(color)
[2020.11.28提高组模拟]T1染色(color) 题目 题目描述 给定 \(n\),你现在需要给整数 \(1\) 到 \(n\) 进行染色,使得对于所有的 \(1\leq i<j\leq ...
- 【CF Round 434 B. Which floor?】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF edu 30 D. Merge Sort】
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- 【Cf edu 30 B. Balanced Substring】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【2020.11.28提高组模拟】T2 序列(array)
序列(array) 题目描述 给定一个长为 \(m\) 的序列 \(a\). 有一个长为 \(m\) 的序列 \(b\),需满足 \(0\leq b_i \leq n\),\(\sum_{i=1}^ ...
- 01 语言基础+高级:1-3 常用API第一部分_day08【String类、static、Arrays类、Math类】
day08[String类.static.Arrays类.Math类] String类static关键字Arrays类Math类 教学目标能够使用String类的构造方法创建字符串对象能够明确Stri ...
- B. Lost Number【CF交互题 暴力】
B. Lost Number[CF交互题 暴力] This is an interactive problem. Remember to flush your output while communi ...
随机推荐
- SAP 文本框实例
SAP 文本框 简单实例 REPORT ZTEST001. DATA: OK_CODE LIKE SY-UCOMM, SAVE_OK LIKE SY-UCOMM. DATA: REF_EDIT_CTN ...
- 多任务版udp聊天器
import socket import threading def send_msg(udp_socket): """获取键盘数据,并将其发送给对方"&quo ...
- MySQL 如何生成月份表
MySQL 如何生成月份表 如果遇到按照月份统计信息的时候,常用的统计方式就是用month表去连接order表,下面就是生成月份表的过程 1.首先是建表 CREATE TABLE `sn_month` ...
- 在CentOS VPS上通过SSH安装 MySQL
输入 yum install mysql-server 按Y继续 安装完成,设置开机启动Mysql,输入 chkconfig --levels 235 mysqld on 然后启动tomcat,输入s ...
- MySQL Limit 限定查询记录数
MySQL Limit 限定查询记录数 MySQL LIMIT MySQL 中 LIMIT 关键字用于限定查询记录返回最大数目. 语法: ... LIMIT offset , rows 该语法中,of ...
- php图片上传旋转压缩方法
用到php的exif扩展,需要开启exif 在php.ini文件中去掉exif组件的注释 extension=php_mbstring.dll //要放在php_exif.dll前面让它先加载 ext ...
- 浅谈UWB(超宽带)室内定位技术(转载)
技术背景 随着无线通信技术的发展和数据处理能力的提高,基于位置的服务成为最有前途的互联网业务之一.无论移动在室内还是室外环境下,快速准确地获得移动终端的位置信息和提供位置服务的需求变得日益迫切.通信和 ...
- 猴子吃桃问题 python
猴子第一天摘下若干个桃子,当即吃了一半,还不瘾,又多吃了一个,第二天早上又将剩下的桃子吃掉一半,又多吃了一个.以后每天早上都吃了前一天剩下的一半零一个.到第10天早上想再吃时,见只剩下一个桃子了.求第 ...
- 【UE4】二十三、UE4笔试面试题
在CSDN博客看到的,带着这些问题,多多留意,正所谓带着问题学习. 一. 1.Actor的EndPlay事件在哪些时候会调用? 2.BlueprintImplementableEvent和Bluepr ...
- Servlet过滤器---编码转换过滤器
该实例用于将请求与相应的编码设置为当前网站的默认编码 java类: import java.io.IOException; import javax.servlet.Filter; import ja ...