当前位置:网站首页>Codeforces Round #794 (Div. 2)(A.B.C)
Codeforces Round #794 (Div. 2)(A.B.C)
2022-07-24 17:44:00 【Evil_ boy__】
A. Everything Everywhere All But One
Topic link :
Topic :
The question :
Yes n Number , You can choose n - 1 Numbers make these numbers here n-1 The arithmetic mean of the number . Ask if you can change these numbers into all the same values
Ideas :
One n Number , You can choose n-1 Number , Then we can enumerate each number as the unselected number , Then see whether the arithmetic mean of other numbers is equal to the unselected value
Code :
#include<bits/stdc++.h>
using namespace std;
int arr[55];
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
double sum = 0;
for(int i = 0; i < n; i++){
cin >> arr[i];
sum += arr[i];
}
bool f = 0;
for(int i = 0; i < n; i++){
if((sum - arr[i]) / (n - 1) == arr[i]){
f = 1;
break;
}
}
if(f){
cout << "YES" << endl;
}else{
cout << "NO" << endl;
}
}
return 0;
}B. Odd Subarrays
Topic link :
Topic :

The question :
An array b, If i<j also ai>aj, So this pair (i,j) Even a reversal number , If the number of inverses of this array is odd , Then say that this array is odd . Ask how many consecutive odd subarrays you can split an array into
Ideas :
We ask for the most , that 2 The number of people in a group is the largest , If ai > ai+1, Then you can put these two together , Just divide the others into groups
Code :
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> arr[i];
}
int num = 0;
for(int i = 0; i < n - 1; i ++){
if(arr[i] > arr[i + 1]){
num++;
i++;
}
}
cout << num << endl;
}
return 0;
}C. Circular Local MiniMax
Topic link :
Topic :


The question :
Given some numbers , Change the position of the number , Ask whether these numbers can be enclosed into a garden , The intermediate value is required to be smaller than that of both adjacent walls , Or bigger than both sides
Ideas :
If the number of these numbers is odd , Then you can never be satisfied , If it's even , Sort these Numbers from small to large , And then the front n/2 One and the back n/2 Alternate square . For the last time , Judge whether it will be the same
Code :
#include<bits/stdc++.h>
using namespace std;
int arr[100005];
int b[100005];
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> arr[i];
}
sort(arr, arr + n);
if(n & 1){
cout << "NO" << endl;
continue;
}else{
int a = 0;
for(int i = 0; i < n / 2; i++){
b[a] = arr[i];
a++;
b[a] = arr[n / 2 + i];
a++;
}
}
bool f = 0;
for(int i = 1; i < n - 1; i++){
if(b[i] == b[i - 1] || b[i] == b[i + 1]){
f = 1;
}
}
if(b[0] == b[n - 1]){
f = 1;
}
if(f){
cout << "NO" << endl;
}else{
cout << "YES" << endl;
for(int i = 0; i < n; i++){
if(i != 0){
cout << " ";
}
cout << b[i];
}
cout << endl;
}
}
return 0;
}边栏推荐
- 【网络安全】网站中间件存在的解析漏洞
- Is computer monitoring true? Four experiments to find out
- 微信朋友圈的高性能复杂度分析
- Common questions of testers during interview
- Review and analysis of noodle dishes
- wallys/IPQ8074A 4x4 2.4G 8x8 5G 802.11ax
- 单细胞代码解析-妇科癌症单细胞转录组及染色质可及性分析1
- Getaverse, a distant bridge to Web3
- Awk from getting started to getting into the ground (19) awk extensions make awk even stronger
- Use Matplotlib to simulate linear regression
猜你喜欢

Opencv has its own color operation

Atcoder Beginner 202 E - Count Descendants(离线查询 重链剖分树上启发式合并)

数论整除分块讲解 例题:2021陕西省赛C

Iftnews | Christie's launched its venture capital department, aiming at Web3 and metauniverse industries

ansible自动化运维详解(五)ansible中变量的设定使用、JINJA2模板的使用以及ansible的加密控制

DF2NET三维模型部署

Getaverse,走向Web3的远方桥梁

Today, I met a 38K from Tencent, which let me see the ceiling of the foundation

OpenCV 图片旋转

700. Search DFS method in binary search tree
随机推荐
Natbypass port forwarding
Detailed explanation of ansible automatic operation and maintenance (V) the setting and use of variables in ansible, the use of jinja2 template and the encryption control of ansible
ROC and AUC details of the recommended system
Getaverse,走向Web3的远方桥梁
C语言实现静态版本的通讯录
Js实现继承的六种方式
213. Looting II - Dynamic Planning
Iqiyi Tiktok reconciled, Weibo lying gun?
2022 牛客暑期多校 K - Link with Bracket Sequence I(线性dp)
Is Shenwan Hongyuan securities' low commission account reliable, reliable and safe
wallys/IPQ8074A 4x4 2.4G 8x8 5G 802.11ax
阿里巴巴/1688按图搜索商品(拍立淘) API使用说明
Awk from entry to earth (17) awk multiline writing
Two dimensional convolution -- use of torch.nn.conv2d
Use prometheus+grafana to monitor MySQL performance indicators
C language custom type explanation - Consortium
Demonstration experiment of scrollbar for adjusting image brightness
Today, I met a 38K from Tencent, which let me see the ceiling of the foundation
Can CSC open an account for domestic futures? Is it safe?
Niuke linked list solution record