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】的更多相关文章

  1. 【CF Edu 28 C. Four Segments】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. 【CF Edu 28 A. Curriculum Vitae】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  3. 【2020.11.28提高组模拟】T1染色(color)

    [2020.11.28提高组模拟]T1染色(color) 题目 题目描述 给定 \(n\),你现在需要给整数 \(1\) 到 \(n\) 进行染色,使得对于所有的 \(1\leq i<j\leq ...

  4. 【CF Round 434 B. Which floor?】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  5. 【CF edu 30 D. Merge Sort】

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. 【Cf edu 30 B. Balanced Substring】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  7. 【2020.11.28提高组模拟】T2 序列(array)

    序列(array) 题目描述 ​给定一个长为 \(m\) 的序列 \(a\). 有一个长为 \(m\) 的序列 \(b\),需满足 \(0\leq b_i \leq n\),\(\sum_{i=1}^ ...

  8. 01 语言基础+高级:1-3 常用API第一部分_day08【String类、static、Arrays类、Math类】

    day08[String类.static.Arrays类.Math类] String类static关键字Arrays类Math类 教学目标能够使用String类的构造方法创建字符串对象能够明确Stri ...

  9. B. Lost Number【CF交互题 暴力】

    B. Lost Number[CF交互题 暴力] This is an interactive problem. Remember to flush your output while communi ...

随机推荐

  1. LINUX安装好后无法访问网络

    LINUX安装好后无法访问网络 在虚拟机安装好新的LINUX系统后,ping www.baidu.com ,发现无法ping通. 键入ifconfig查询配置: eno16777728: flags= ...

  2. Python学习之购物车

    实现功能: 程序启动,提示用户输入用户名和密码,程序读取余额文件last_salary.txt内容(文件不存在则自动创建),若文件内容为空则提示“首次登录,请输入工资”: 用户可以输入商品编号进行购买 ...

  3. 「译」setState如何知道它该做什么?

    本文翻译自:How Does setState Know What to Do? 原作者:Dan Abramov 如果有任何版权问题,请联系shuirong1997@icloud.com 当你在组件中 ...

  4. 【c学习-6】

    void myFunction4(){ //根据用户字段和密码字段判定是否允许登录 //定义原密码和用户字段 char user[10]={"liupeng"};//设置用户名字段 ...

  5. Codeforces Round #460 (Div. 2): D. Substring(DAG+DP+判环)

    D. Substring time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...

  6. cf978E Bus Video System

    The busses in Berland are equipped with a video surveillance system. The system records information ...

  7. 第一章:Hello, World!

    感谢作者 –> 原文链接 本文翻译自The Flask Mega-Tutorial Part I: Hello, World! 一趟愉快的学习之旅即将开始,跟随它你将学会用Python和Flas ...

  8. java身份证计算年龄

    技术交流群: 233513714 /** * 根据身份证计算年龄 * * @param idcard * @return */ public static Integer idCardToAge(St ...

  9. build dynamic libraries for iOS and load them at runtime

    编译了libmt.dylib, 和 test 程序调用,均正常.在xcode中显示调用正常,隐式调用则出现问题. 提示 dyld: Library not loaded. 即使存在在/usr/lib/ ...

  10. React02

    目录 React 进阶提升 条件渲染 受控组件* 状态提升* 组件数据流 TODO-LIST 设置服务器端口 列表渲染 条目PropTypes检查类型 export & import Refs ...