列表

详情


NC221637. Mr.Maxwellandattractions

描述

Mr. Maxwell is an employee of an enterprise. He works either in the morning or in the afternoon. If working in the morning, he will visit attraction with his family in A city in the afternoon. If working in the afternoon, he will do the visit in the morning. He can only visit one attraction each day. There are  indoor attractions and  outdoor attractions in A city, and there's a specified  for each attraction. Consider the pleasure he got from the attraction each time he visited as .


The  Mr.Maxwell gets each time he visits the attraction is equal to the current  of the attraction multiplied by the conversion rate of this visit.

For each attraction, the conversion rate from its current  to  is  on the first visit, and for each repeat visit, it is reduced to  of the previous one.

For outdoor attractions, their  is reduced to  in the afternoon, but will be restored every morning.

For instance, if Mr.Maxwell visits an outdoor attraction which hasn't been visited before in the afternoon, with the  , the  for this visit should be . If he visits the same attraction once again, the  he gets will be  in the morning, or  in the afternoon.

Now there are  days left in this quarter.
Mr. Maxwell is free to choose to work in the morning or afternoon, but the number of morning-working days must be equal to or greater than .
Please calculate the maximum sum of  he can get.

输入描述

The first line contains four integers  .

The second line contains  integers, the  integer  denotes the beauty value of the  indoor attraction.

The third line contains  integers, the  integer  denotes the beauty value of the  outdoor attraction.

输出描述

Output one real number representing the maximum sum of pleasure value Mr. Maxwell can get in next  days. The result should be rounded up to 2 decimal places.

示例1

输入:

2 1 4 2
4 3
7

输出:

18.20

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++(clang++11) 解法, 执行用时: 98ms, 内存消耗: 3492K, 提交时间: 2021-05-08 20:06:25

#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<double>in,out;
	int n,m,t,k;
	cin>>n>>m>>t>>k;
	for(int i=0;i<n;i++){
		double a;
		cin>>a;
		in.push(a);
	}
	for(int i=0;i<m;i++){
		double a;
		cin>>a;
		out.push(a);
	}
	
	k = t-k;
	double sum = 0,f = 1;
	for(int i=0;i<t;i++){
		if(k == 0)f = 0.8;
		double x = in.top();
		double y = out.top();
		if(x<y*f){
			sum+=y*f;
			k--;
			out.pop();
			out.push(y*0.6);
		}else{
			sum+=x;
			in.pop();
			in.push(x*0.6);
		}
	}
	printf("%.02f",sum);
} 

上一题