当前位置:网站首页>organize a team
organize a team
2022-07-21 22:38:00 【Long Xingchen】
4413. organize a team
Given n It's an integer y1,y2,…,yn, And an integer k.
First find out how many yi Satisfy yi+k≤5, Then output the data that meets the requirements yi Number of divided by 3 Rounded down value .
Input format
The first line contains two integers n and k.
The second line contains n It's an integer y1,y2,…,yn.
Output format
An integer , Answer .
Data range
front 4 Test points meet 1≤n≤6.
All test points meet 1≤n≤2000 1≤k≤5 0≤yi≤5.
sample input 1:
5 2
0 4 5 1 0
sample output 1:
1
sample input 2:
6 4
0 1 2 3 4 5
sample output 2:
0
sample input 3:
6 5
0 0 0 0 0 0
sample output 3:
2
The question is AcWing The first 49 The first question of the week , The difficulty is not so high , It can be done without Algorithm .
First light code :
#include <iostream>
using namespace std;
int main()
{
int n,k,sum=0;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]+k<=5)
sum++;
}
cout<<sum/3<<endl;
}
The whole code is very short , Only 15 OK, it's so short , In the input a[i] You can start recording and k The sum is less than or equal to , You don't have to use one later for Loop to calculate , It's a waste of time , Finally, output the record directly (sum) Divide 3 That's it , because int Variable to divide, the default is to round down , There's no need for that trouble !
too I'll explain the second question later , Thank you. .
边栏推荐
- Analysis of the characteristics of matter protocol (I) support non matter protocol, private protocol, and technical analysis of matter Bridge
- Teach you how to use yolov4 training and testing data set on the server (nanny level)
- P/NP/NP完全/NP难
- The 22 pictures show you in-depth analysis of prefix, infix, suffix expressions and expression evaluation
- 205. 同构字符串
- Characteristics and differences between PCB and integrated circuit
- datart 自定义插件,不改动源代码,让 BI 顺利完成又一次创新
- Open source data visualization tool datart new user experience tutorial for popular communities
- 994. 腐烂的橘子
- RobotFramework(ride)关键字无法使用或关键字为黑色
猜你喜欢
概率论-方差和协方差、相关系数
03-selenium的自动化测试模型
In depth analysis of multiple knapsack problem (Part 2)
What is PCBA? What is the importance of PCBA testing?
This Bluetooth chip giant aims at the WiFi SOC market and launches a low-power WiFi MCU product line
What is the Internet of things control system? What are its characteristics?
Blockbuster: the domestic ide was released and developed by Alibaba. It is completely open source (high performance + high customization)
01- fundamentals of automated testing -- (selenium eight part + environment configuration + eight positioning)
One article explains the problem of data fragmentation in distributed systems
流批一体?实时数据处理场景化应用实例~
随机推荐
62. 不同路径
03-selenium的自动化测试模型
robotframework--浏览器驱动和操作的实现(1)
干货 | 分布式系统的数据分片难题
概率论-方差和协方差、相关系数
Introduction to general process choreography engine
Comprehensive: realtek/ Ruiyu wireless product map and market composition
企业如何做好数据管理?产品选型怎么做?
XML详解
堆-原理到應用——堆排序、優先級隊列
ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!
04-unittest单元测试框架
LinkedList源码深度剖析
Mstest cannot exit
Easily self-made Pascal VOC dataset
148. 排序链表
Yolov4 (Darknet version) post processing: display confidence and save the contents of the detection box locally
快速排序
In depth analysis of multiple knapsack problem (Part 2)
组队