当前位置:网站首页>[daily question in summer] first time, second time, deal!
[daily question in summer] first time, second time, deal!
2022-07-01 04:47:00 【AC_ Dragon】
Title Description
Because the diet exercise of cows gives FJ There's a lot of hay left that can't be handled , So he's going to open an auction to sell his hay .
He has n A batch of hay ( Each batch is about 100 bundle ). His clients are m individual , All the farmers next to him . The first i A farmer will tell FJ He will do it for FJ Pay for each batch of hay pi The money . Every farmer wants to buy ( I just want to buy )FJ A batch of forage .
To make sure farmers don't envy each other , therefore FJ Decided to sell his forage at a fixed price . Each bid is better than FJ Farmers who ask higher prices will buy forage , The rest will be rejected .
Please help FJ Find out the lowest price of a single batch of forage that can make him the most money .
Input format
first line : Two integers separated by spaces ,n and m.
Line two to line two m+1 That's ok : The first i+1 The line contains only one integer :pi.
Output format
All in one line , Contains two integers separated by spaces :FJ The lowest price of each batch of forage that can be offered , And the most money he can make .
Examples #1
The sample input #1
5 4
2
8
10
7Sample output #1
7 21Tips
FJ Yes 5 Batch forage ,4 A farmer wants to buy . Their bids are : Each batch of forage is 2,8,10 and 7.
FJ The price should be set to 7, There will be 3 A farmer will pay for forage ,FJ I'll earn it 21 The money .
---
about 100% The data of ,1<= n <= 1000,1<= m <= 1000,1<= pi <= 1,000,000.
AC code:
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[m];
for(int i=0;i<m;i++)
cin>>a[i];
sort(a,a+m);
int res=0;
int r;
for(int i=0;i<m;i++)
{
if(a[i]*(m-i)>res)
r=a[i];
if((m-i)<=n)
res=max(a[i]*(m-i),res);
else
res=max(a[i]*n,res);
}
cout<<r<<" "<<res;
return 0;
}边栏推荐
- Announcement on the list of Guangdong famous high-tech products to be selected in 2021
- Pytorch(二) —— 激活函数、损失函数及其梯度
- pytorch神经网络搭建 模板
- Leecode question brushing record 1310 subarray XOR query
- JVM栈和堆简介
- [difficult] sqlserver2008r2, can you recover only some files when recovering the database?
- Shell之一键自动部署Redis任意版本
- Use and modification of prior network model
- LeetCode_ 28 (implement strstr())
- C -- array
猜你喜欢

神经网络-非线性激活
![[hard ten treasures] - 1 [basic knowledge] classification of power supply](/img/a8/f129c9d15ca6ed99db1dacfc750ead.png)
[hard ten treasures] - 1 [basic knowledge] classification of power supply

VIM easy to use tutorial

Neural network - nonlinear activation

Pytoch (III) -- function optimization

2022.2.7-2.13 AI industry weekly (issue 84): family responsibilities

STM32扩展版 按键扫描

技术分享| 融合调度中的广播功能设计

Pytorch(一) —— 基本语法

The design points of voice dialogue system and the importance of multi round dialogue
随机推荐
2022-02-15 (399. Division evaluation)
【暑期每日一题】洛谷 P7222 [RC-04] 信息学竞赛
Introduction to JVM stack and heap
The junior college students were angry for 32 days, four rounds of interviews, five hours of soul torture, and won Ali's offer with tears
1076 Forwards on Weibo
Neural network - nonlinear activation
Pytorch(四) —— 可视化工具 Visdom
RuntimeError: mean(): input dtype should be either floating point or complex dtypes. Got Long instead
VIM easy to use tutorial
Dataloader的使用
扩展-Fragment
pytorch中常用数据集的使用方法
STM32 extended key scan
[hardware ten treasures catalogue] - reprinted from "hardware 100000 whys" (under continuous update ~ ~)
神经网络的基本骨架-nn.Moudle的使用
One click shell to automatically deploy any version of redis
Summary of testing experience - Testing Theory
Common interview questions ①
2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
How to do the performance pressure test of "Health Code"