当前位置:网站首页>[getting started] input n integers and output the smallest K of them
[getting started] input n integers and output the smallest K of them
2022-07-01 07:59:00 【-Heaven rewards diligence-】
describe
Input n It's an integer , Find out the smallest k An integer and output in ascending order
Input description
Enter two integers on the first line n and k
On the second line, enter an array of integers
Output description
From small to large, output the smallest k It's an integer , Separate with spaces .
Example 1
Input :5 2
1 3 5 7 2
Output :1 2
<?php
$num = fgets(STDIN);
$data = fgets(STDIN);
// Total array length and You need to intercept the length of the array
$num_arr = explode(' ',trim($num,"\t\n\r"));
// Intercept the required length
$data_arr = array_slice(explode(' ',trim($data,"\t\n\r")),0,$num_arr[0]);
// Sort From small to large
sort($data_arr);
// Intercept the required array
$res_arr = array_slice($data_arr,0,$num_arr[1]);
echo implode(" ",$res_arr);

边栏推荐
- Set up file server Minio for quick use
- 2022 test questions and mock examinations for main principals of hazardous chemicals business units
- php laravel微信支付
- 软键盘高度报错
- Missing API interface actual development series (14): ID card real name authentication verification
- Aardio - [problem] the problem of memory growth during the callback of bass Library
- The triode is a great invention
- 长路漫漫、技术作伴
- Microsoft stream - how to modify video subtitles
- The Windows C disk is full
猜你喜欢

Aardio - 阴影渐变文字

The triode is a great invention
![[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions](/img/2c/07d729d49b1d74553decac4588074e.png)
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions
![[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario](/img/10/ed857892d2e0ea72e100a4008e6d69.png)
[recommendation system] breakthrough and imagination of deep location interactive network dpin for meituan takeout recommendation scenario

2022 mobile crane driver test exercises and online simulation test

【无标题】

MATLAB之基础知识

postgresql源码学习(26)—— Windows vscode远程调试Linux上的postgresql

【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
![[MySQL learning notes 25] SQL statement optimization](/img/01/cf0556961670bb43512caab8d5f4e5.png)
[MySQL learning notes 25] SQL statement optimization
随机推荐
sqlalchemy创建MySQL_Table
漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
Basic number theory -- combinatorial number
php laravel微信支付
PostgreSQL source code learning (26) -- windows vscode remote debugging PostgreSQL on Linux
2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) special operation certificate examination question bank simulated examination platform operation
IMDB practice of emotion classification (simplernn, LSTM, Gru)
良心安利万向轮 SolidWorks模型素材网站
kubernetes资源对象介绍及常用命令(二)
Set up file server Minio for quick use
2022危险化学品经营单位主要负责人试题及模拟考试
软件测试方法和技术 - 基础知识概括
[untitled]
She is the "HR of others" | ones character
EDA开源仿真工具verilator入门6:调试实例
Deep learning systematic learning
Discussion on several research hotspots of cvpr2022
MATLAB之基础知识
Gdip - hatchBrush图案表