题目描述:
在系统、网络均正常的情况下组织核酸采样员和志愿者对人群进行核酸检测筛查。每名采样员的效率不同,采样效率为N人/小时。由于外界变化,采样员的效率会以M人/小时为粒度发生变化,M为采样效率浮动粒度,M=N*10%,输入保证N*10%的结果为整数。采样员效率浮动规则:采样员需要一名志愿者协助组织才能发挥正常效率,在此基础上,每增加一名志愿者,效率提升1M,最多提升3M;如果没有志愿者协助组织,效率下降2M。怎么安排速度最快?求总最快检测效率(总检查效率为各采样人员效率值相加)。
输入描述:
第一行:第一个值,采样员人数,取值范围[1,100];第二个值,志愿者人数,取值范围[1,500];第二行:各采样员基准效率值(单位人/小时),取值范围[60,600],保证序列中每项值计算10%为整数
输出描述:
第一行:总最快检测效率(单位人/小时)补充说明:
输入需要保证采样员基准效率值序列的每个值*10%为整数收起
示例1
输入:
2 2
200 200
输出:
400
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int cyyNum = in.nextInt();
int zyzNum = in.nextInt() + 1;
//只剩多少个志愿者时的最大值
int[] maxArr = new int[zyzNum];
for (int i = 0; i < cyyNum; i++) {
int n = in.nextInt();
int m = (int) (n * 0.1);
for (int j = 0; j < zyzNum; j++) {
//不用志愿者
int max = maxArr[j] + n - 2 * m;
//用一个志愿者
if (j + 1 < zyzNum) {
max = Math.max(max, maxArr[j + 1] + n);
}
//用两个志愿者
if (j + 2 < zyzNum) {
max = Math.max(max, maxArr[j + 2] + n + m);
}
//用三个志愿者
if (j + 3 < zyzNum) {
max = Math.max(max, maxArr[j + 3] + n + m * 2);
}
//用四个志愿者
if (j + 4 < zyzNum) {
max = Math.max(max, maxArr[j + 4] + n + m * 3);
}
maxArr[j] = max;
}
}
//找到最大值
int max = 0;
for (int i:maxArr){
max = Math.max(i,max);
}
System.out.println(max);
}
}
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int sample_member_num, volunteer_member_num;
vector<int> sample_efficiency = {};
vector<int> volunteer_capacity = {};
cin >> sample_member_num >> volunteer_member_num;
int temp_efficiency;
int res = 0;
for (int i = 0; i < sample_member_num; i++)
{
cin >> temp_efficiency;
sample_efficiency.emplace_back(temp_efficiency);
volunteer_capacity.emplace_back(3);
}
std::sort(sample_efficiency.begin(), sample_efficiency.end(), [](auto const &a, auto const &b)
{return a >= b;});
vector<int> increase = {};
for (const auto &i : sample_efficiency)
{
res += i;
increase.push_back(0.2 * i);
int temp = 0.1 * i;
for (int i = 0; i < 3; i++)
{
increase.push_back(temp);
}
}
res = 0.8*(res);
std::sort(increase.begin(), increase.end(), [](auto const &a, auto const &b)
{return a >= b;});
for (int i = 0; i < volunteer_member_num; i++)
{
if (i >= increase.size())
{
break;
}
//cout << res << " ";
res += increase[i];
}
// Determine if any one who does not need a volunteer
cout << res;
return 0;
}