CF846B.Math Show

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Polycarp takes part in a math show. He is given nn tasks, each consists of kk subtasks, numbered 11 through kk . It takes him tjt_{j} minutes to solve the jj -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 kk of its subtasks), he recieves one extra point. Thus, total number of points he recieves for the complete solution of the task is k+1k+1 .

Polycarp has MM minutes of time. What is the maximum number of points he can earn?

输入格式

The first line contains three integer numbers nn , kk and MM ( 1<=n<=451<=n<=45 , 1<=k<=451<=k<=45 , 0<=M<=21090<=M<=2·10^{9} ).

The second line contains kk integer numbers, values tjt_{j} ( 1<=tj<=10000001<=t_{j}<=1000000 ), where tjt_{j} is the time in minutes required to solve jj -th subtask of any task.

输出格式

Print the maximum amount of points Polycarp can earn in MM minutes.

输入输出样例

  • 输入#1

    3 4 11
    1 2 3 4
    

    输出#1

    6
    
  • 输入#2

    5 5 10
    1 2 4 8 16
    

    输出#2

    7
    

说明/提示

In the first example Polycarp can complete the first task and spend 1+2+3+4=101+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 51=55·1=5 minutes. Also he can solve the second subtasks of two tasks and spend 22=42·2=4 minutes. Thus, he earns 5+2=75+2=7 points in total.

首页