当前位置:网站首页>Children play games (greed, prefix and) - Niuke winter vacation training camp
Children play games (greed, prefix and) - Niuke winter vacation training camp
2022-06-26 07:20:00 【Sss_ xxh、】
Original link
subject
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-20xD2fDG-1644926053066)(https://hbn31pkbuk.feishu.cn/space/api/box/stream/download/asynccode/?code=YjcxMjIxNTYwYTg3Y2E4MGNiZWFjMDBhMDFiMmRmZGFfazBraWlyWHd0WklBUjBFTVVWbWJjU21mOUpnTEVIWkZfVG9rZW46Ym94Y243bW9PbEVab1BkN1hrelRSdGxkNGlnXzE2NDQ5MjI5MzE6MTY0NDkyNjUzMV9WNA)]](/img/c2/b8a0c53f34e3d69916814f8c5b4311.jpg)
Ideas
- First, meet the requirements ( Every two noisy children need a quiet child ), Well, at most there can only be n / 2 n/2 n/2 A noisy child
- If the number of quiet children is insufficient n / 2 + n m o d 2 n/2+n\ mod\ 2 n/2+n mod 2 , It outputs
-1. - For the rest, let the quiet children and the noisy children rank in descending order of happiness .
- Then find the prefix sum
- The last comparison is in the least use n / 2 n/2 n/2 What is the greatest happiness of a quiet child .
Code
//
// Created by saber on 2022/2/15.
//
#include<bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
int suma[N] = {
0};
int sumb[N] = {
0};
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
int t; cin >> t;
while (t -- )
{
int a, b, n;
cin >> a >> b >> n;
memset(suma, 0, sizeof suma);
memset(sumb, 0, sizeof sumb);
for (int i = 1; i <= a; i ++ )
{
cin >> suma[i];
}
for (int i = 1; i <= b; i ++ )
{
cin >> sumb[i];
}
sort(suma + 1, suma + 1 + a, cmp);
sort(sumb + 1, sumb + 1 + b, cmp);
for (int i = 1; i <= a; i ++ )
{
suma[i] += suma[i - 1];
}
for (int i = 1; i <= b; i ++ )
{
sumb[i] += sumb[i - 1];
}
int maxn = 0;
int f = n/2 + (n % 2);
if (a < f)
{
cout << -1 << endl;
continue;
}
for (int i = f; i <= min(a, n); i ++ )
{
maxn = max(suma[i] + sumb[n - i], maxn);
}
cout << maxn << endl;
}
return 0;
}
summary
I don't understand , Why such a simple topic , But I couldn't write it out during the game .
边栏推荐
- i3wm 获取window class
- . Net 20th anniversary! Microsoft sends a document to celebrate
- [feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
- MySQL operation database
- One chip realizes functions such as spray 𞓜 ws2812 drive | key touch | LED display | voice broadcast chip and simplifies the design of humidifier products
- Quickly find five channels for high-quality objects, quickly collect and avoid detours
- Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue
- Redis series - redis startup, client day1-2
- 数据中心灾难恢复的重要参考指标:RTO和RPO
- Liangshui Xianmu shows his personal awareness as a unity3d worker
猜你喜欢

Solution to the permission problem when NPM install -g serve reports an error
![[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]](/img/7b/43becce42192fb5e0469465aa27a36.png)
[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]

GMP model

缓存使用

MySQL
![[yolov4] matlab simulation of network target detection based on yolov4 deep learning](/img/f9/31aba8f8bc04ccb16486dc87712ef6.png)
[yolov4] matlab simulation of network target detection based on yolov4 deep learning

Young man, do you know the original appearance of kotlin association process?

Machine learning - Iris Flower classification

Kalman filter_ Recursive Processing

Big factory interview TCP protocol classic 15 consecutive questions! 22 pictures to make you fully understand
随机推荐
[feature extraction] feature selection of target recognition information based on sparse PCA with Matlab source code
MySQL 'replace into' 的坑 自增id,备机会有问题
蓝桥杯嵌入式学习总结(新版)
JS modularization
[image detection] image target size measurement system based on morphology with matlab code
Jemter 压力测试 -可视化工具支持-【安装篇】
Young man, do you know the original appearance of kotlin association process?
两水先木示身为Unity3D职场人的个人觉悟
Ppbpi-h-cr, ppbpimn Cr, ppbpi Fe Cr alkynyl crosslinked porphyrin based polyimide material Qiyue porphyrin reagent
MySQL
Calculate division in Oracle - solve the error report when the divisor is zero
Liquid crystal texture diagram of purple solid mm-tpp-10c methacrylic acid decanoxy tetraphenyl porphyrin and mm-tpp-12c methacrylic acid dodecanoxy tetraphenyl porphyrin - Qi Yue display
php array_ Merge details
Big factory interview TCP protocol classic 15 consecutive questions! 22 pictures to make you fully understand
In depth analysis of redis object structure
When asked during the interview, can redis master-slave copy not answer? These 13 pictures let you understand thoroughly
Request&Response
ZRaQnHYDAe
Sanic based services use celery to complete dynamic modification timing tasks
5,10,15,20-tetra (4-bromophenyl) porphyrin (h2tppbr4) /5.2.15,10,15,20-tetra [4-[(3-aminophenyl) ethynyl] phenyl] porphyrin (tapepp) Qiyue porphyrin reagent