当前位置:网站首页>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 .
边栏推荐
- Jemter 压力测试 -可视化工具支持-【安装篇】
- Golang源码包集合
- 两水先木示身为Unity3D职场人的个人觉悟
- Flutter (III) - master the usage of dart language in an article
- C implementation adds a progress bar display effect to the specified column of the GridView table in devaxpress - code implementation method
- Solution to the permission problem when NPM install -g serve reports an error
- GMP模型
- 5,10,15,20-tetraphenylporphyrin (TPP) and metal complexes fetpp/mntpp/cutpp/zntpp/nitpp/cotpp/pttpp/pdtpp/cdtpp supplied by Qiyue
- Market survey of China's coal to liquid industry and analysis report on investment competitiveness during the "14th five year plan" 2022-2027
- Crosslinked metalloporphyrin based polyimide ppbpi-h) PPBP Mn; PBP-Fe; PPBPI-Fe-CR; Ppbpi Mn CR product - supplied by Qiyue
猜你喜欢

Parameter index out of range (0 < 1) (1> number of parameters, which is 0

5,10,15,20-tetraphenylporphyrin (TPP) and metal complexes fetpp/mntpp/cutpp/zntpp/nitpp/cotpp/pttpp/pdtpp/cdtpp supplied by Qiyue

Cache usage

Cocoscreator plays spine animation

快速找到优质对象的5种渠道,赶紧收藏少走弯路

Stm32f1 and stm32subeide programming example - thermal sensor driver
![[image fusion] multimodal medical image fusion based on coupled feature learning with matlab code](/img/50/e48b9fa1cfbbb183285a8e41c77119.png)
[image fusion] multimodal medical image fusion based on coupled feature learning with matlab code
![[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]

Dark red crystal meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin (co TAPP); Meso-5,10,15,20-tetra (p-aminophenyl) cobalt porphyrin no complex (TAPP co no) supplied by Qiyue

ZRaQnHYDAe
随机推荐
Numpy learning challenge level 5 - create array
[image fusion] MRI-CT image fusion based on gradient energy, local energy and PCA fusion rules with matlab code
es 中 mapping 简介
少年,你可知 Kotlin 协程最初的样子?
php array_ Merge details
网络io,磁盘io
Database persistence
Teach you how to use the harmonyos local simulator
[image enhancement] image defogging based on artificial multiple exposure fusion amef with matlab code
Stm32f1 and stm32subeide programming example - thermal sensor driver
Cache usage
Shengshi Haotong enterprise wechat sector creates a digital ecological community
一文搞懂Glide,不懂来打我
Multisensor fusion sensing
item2安装配置及环境失效问题解决
数据中心灾难恢复的重要参考指标:RTO和RPO
Iron / zinc / copper / platinum metal complexes such as 5,10,15,20-tetra (4-hydroxyphenyl) porphyrin (THPP) / (thppfe) / (thppzn) / (thppcu) / (thpppt) - Qiyue R & D
[recommend an entity class conversion tool mapstruct, which is powerful and easy to use]
基于sanic的服务使用celery完成动态修改定时任务
13. Mismatch simulation of power synthesis for ads usage recording