当前位置:网站首页>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;
}边栏推荐
- Get the data of Tongcheng (elong) Hotel
- 近30所高校,获教育部点名表扬!
- After separation, the impression notes are still difficult to live, but there are many coquettish operations
- Practical application cases of digital Twins - Smart Park
- Baidu PaddlePaddle easydl x wesken: see how to install the "eye of AI" in bearing quality inspection
- 简单测试JS代码
- SV强制类型转换和常数
- How to remove the top picture of the bubble skin article details of solo blog
- Tensorflow introductory tutorial (37) -- DC Vnet
- 深入解析著名的阿里云Log4j 漏洞
猜你喜欢

Can Lu Zhengyao hide from the live broadcast room dominated by Luo min?

Separation and merging of channels

SV强制类型转换和常数

Openlayers: point aggregation effect

Getaverse, a distant bridge to Web3

The most powerful programmer on the earth is equipped with a "three piece set". Do you know what it is?

Eth POS 2.0 stacking test network pledge process

Get the data of Tongcheng (elong) Hotel

使用matplotlib模拟线性回归

Demonstration experiment of scrollbar for adjusting image brightness
随机推荐
Preliminary study of Oracle pl/sql
微信朋友圈的高性能复杂度分析
数论整除分块讲解 例题:2021陕西省赛C
High performance complexity analysis of wechat circle of friends
快速完成intelij idea的单元测试JUnit4设置
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
DF2NET三维模型部署
生信常用分析图形绘制02 -- 解锁火山图真谛!
After separation, the impression notes are still difficult to live, but there are many coquettish operations
es(1)
近30所高校,获教育部点名表扬!
Can CSC open an account for domestic futures? Is it safe?
Six ways for JS to implement inheritance
Wrote a few small pieces of code, broke the system, and was blasted by the boss
The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced
C语言自定义类型 — 枚举
(mandatory) override equals must override hashcode (principle analysis)
700. 二叉搜索树中的搜索-dfs法
Is it safe for qiniu to open an account?
Socat port forwarding