Time Limits

版权声明:来自星空计算机团队——申屠志刚 https://blog.csdn.net/weixin_43272781/article/details/84032470

A contest setter wants to determine the time limits for a given problem. There are n model
solutions, and solution k takes tk milliseconds to run on the test data. The contest setter wants
the time limit to be an integer number of seconds, and wants the time limit to be at least s times
larger than the slowest model solution. Compute the minimum time limit the contest setter can
set.
Input
The rst line of input contains two space-separated integers n and s (1 n 100 and 1 s 20).
The second line of input contains n space-separated integers t1; : : : ; tn (1 tk 2000 for all
k = 1; : : : ; n).
Output
Print, on one line, the minimum time limit (in seconds) as a single integer.
Sample Input and Output
2 5
200 250
2

Sample Input and Output
3 4
47 1032 1107

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
using namespace std;
int n,s;
int t[200+10];
int main()
{
    scanf("%d%d",&n,&s);
    int maxl=0,ans;
    for(int i=1;i<=n;i++){
        scanf("%d",&t[i]);
        maxl=max(maxl,t[i]);
    }
    ans=maxl*s/1000;
    if(maxl*s%1000)ans++;
    cout << ans << endl;
    //cout << "Hello world!" << endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43272781/article/details/84032470