HDOJ 2019 数列有序!
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
bool cmp(int a, int b) {
return a < b;
}
bool cmp2(int a, int b) {
return a > b;
}
int main() {
int n, m;
&& m != )) {
vector<int> ans;
int t;
while (n--) {
cin >> t;
ans.push_back(t);
}
ans.push_back(m);
] > ans[]) {
sort(ans.begin(), ans.end(), cmp2);
}
else {
sort(ans.begin(), ans.end(), cmp);
}
for (auto it = ans.begin();it != ans.end();it++) {
if (it == ans.begin()) cout << *it;
else cout << " " << *it;
}
cout << endl;
}
;
}
有个坑点,题目中的有序没说是降序还是升序!
HDOJ 2019 数列有序!的更多相关文章
- hdu 2019:数列有序!(数据结构,直接插入排序+折半插入排序)
数列有序! Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submiss ...
- HDU 2019 数列有序!
Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java class name ...
- 杭电2019 数列有序!(STL解法)
由于这题对于学过数据结构的我来说,真的是很简单,为了减少时间上的损失,链表无疑是最好的选择(因为数组要往后移位子).然后,因为最近想玩些STL的骚操作,所以就用<list>了,然后顺便学了 ...
- HDOJ2019数列有序!
数列有序! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- 新疆大学OJ(ACM) 1099: 数列有序!
1099: 数列有序! 时间限制: 1 Sec 内存限制: 128 MB 题目描述 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的 ...
- HDU2019数列有序!
Problem Description 有n(n<=100)个整数,已经按照从小到大顺序排列好,现在另外给一个整数x,请将该数插入到序列中,并使新的序列仍然有序. Input 输入数据包含多个测 ...
- 杭电OJ第11页2010-2019道题(C语言)
2010. 水仙花数 问题描述 Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位 ...
- 杭电oj2012-2021
2012 素数判定 #include <stdio.h> #include <math.h> int main() { int x,y,i,j,a,flag; while(s ...
- 杭电ACM2019--数列有序!
数列有序! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
随机推荐
- stm32l071cbt6片内flash操作
今天在看片内flash的操作,发现按照下面的操作并没有写成功: unsigned long temp = 0x12345678; HAL_FLASH_Unlock(); FLASH_PageErase ...
- LA3485 Bridge
题意 PDF 分析 以<训练指南>上的分析为准. 二分法时间复杂度\(O(\log v)\) 代码 #include<bits/stdc++.h> #define rg reg ...
- POJ2480 Longge's problem
题意 Language:Default Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1064 ...
- day44 数据库学习 索引 引用自egon 老师博客
MySQL索引管理 总结 #索引是存在硬盘中的, #索引的功能, 1.可以加速查询 2.但是他会降低写入和删除的速度 所以不能乱加索引 总结二 1 最左前缀匹配原则 2设置的索引,它的字段中的内容占空 ...
- Spring5 新特性
Spring Framework 5.0是在Spring Framework 4.0之后将近四年内一次重大的升级. 最大特点之一是响应式编程(Reactive Programming). 响应式编程核 ...
- 使用cmake编译luabind
编写了一下cmakelists.txt文件 根目录 cmake_minimum_required(VERSION 2.8)project (Test) add_definitions( "/ ...
- taro 知识点
taro 的包: 包名 说明 @tarojs/redux Redux for Taro @tarojs/redux-h5 Forked react-redux for taro @tarojs/plu ...
- Nginx浏览目录配置及美化
https://segmentfault.com/a/1190000012606305 在项目中有一个功能需要在浏览器页面中浏览服务器的目录.服务器使用Nginx,而Nginx提供了相应的ngx_ht ...
- Linux tee命令详解
Linux tee命令 Linux tee命令用于读取标准输入的数据,并将其内容输出成文件.如果文件指定为"-",则将输入内容复制到标准输出 tee指令会从标准输入设备读取数据,将 ...
- 4G模块luci的配置及重连脚本
一.4G Luci配置 1. 新建一个wwan接口: 2. 上网方式为dhcp自动获取: 3. 物理设置选择wwan0: 4. 防火墙选择wan 二.重连脚本redial4g LogFile=/roo ...