当前位置:网站首页>山寨版归并【上】
山寨版归并【上】
2022-04-23 15:32:00 【MC快乐的苦小怕】
题目:
题目描述
问题描述
可可和乐乐手头有很多游戏卡片,卡片上都有数字编号,他们各自将他们的卡片按照由小到大顺序排序,现在他们想将他们的卡片放到一起,并且还要保证是由小到大排序。由于卡片数目可能达到数百万张,而且要在一秒钟时间完成卡片的合并,现在请你帮忙!
输入格式
共三行。
第一行:空格分隔的两个整数n和m,分别表示可可和乐乐的卡片数;
第二行:n个用空格分隔的整数,表示可可卡片从小到大的编号;
第三行:m个用空格分隔的整数,表示乐乐卡片从小到大的编号;
输出格式
仅一行:n+m个整数,以空格分隔,表示合并后的卡片由小到大的编号。
输入样例
3 4
3 5 7
1 3 4 6
输出样例
1 3 3 4 5 6 7
数据范围
n<=1000000,m<=1000000
这道题开始老师设定的时间是2 Sec,哈哈哈,暴力直接100到手:
定义a[2000010]
接着直接来各个 sort暴力完美。
可是老师见我们操作这么N,就把时间改成了1 Sec。
wawawaw,顿时泪如雨下.
…
shua代码开始
弄了两个“指针”(这里不是*x的那个指针)。
i,j;
话不多说,上代码:
#include <bits/stdc++.h>
using namespace std;
int a[1000010],b[1000010];
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int j=1;j<=m;j++)scanf("%d",&b[j]);
int i=1,j=1;
for(int x=1;x<=n+m;x++){
if(a[i]>b[j])printf("%d ",a[i]),i++;
else printf("%d ",b[j]),j++;
}
return 0;
}
goodbye!!!
山寨版归并【下】传送门
版权声明
本文为[MC快乐的苦小怕]所创,转载请带上原文链接,感谢
https://xiaoguogsc.blog.csdn.net/article/details/122589048
边栏推荐
- My raspberry PI zero 2W toss notes to record some problems and solutions
- Example of time complexity calculation
- Five data types of redis
- Mumu, go all the way
- Knn,Kmeans和GMM
- 移动app软件测试工具有哪些?第三方软件测评小编分享
- Llvm - generate if else and pH
- Crawling fragment of a button style on a website
- Hj31 word inversion
- Connectez PHP à MySQL via aodbc
猜你喜欢
Detailed explanation of kubernetes (XI) -- label and label selector
Detailed explanation of redirection and request forwarding
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
Advanced version of array simulation queue - ring queue (real queuing)
推荐搜索 常用评价指标
Sword finger offer (2) -- for Huawei
X509 certificate cer format to PEM format
Basic operation of sequential stack
木木一路走好呀
KNN, kmeans and GMM
随机推荐
After time judgment of date
Functions (Part I)
Three uses of kprobe
How did the computer reinstall the system? The display has no signal
Deeply learn the skills of parameter adjustment
T2 icloud calendar cannot be synchronized
php类与对象
Explanation of redis database (IV) master-slave replication, sentinel and cluster
adobe illustrator 菜单中英文对照
Design of digital temperature monitoring and alarm system based on DS18B20 single chip microcomputer [LCD1602 display + Proteus simulation + C program + paper + key setting, etc.]
Have you learned the basic operation of circular queue?
[backtrader source code analysis 18] Yahoo Py code comments and analysis (boring, interested in the code, you can refer to)
Squid agent
深度学习——超参数设置
通过 PDO ODBC 将 PHP 连接到 MySQL
什么是CNAS认证?CNAS认可的软件测评中心有哪些?
Tun equipment principle
Explanation of redis database (I)
自动化测试框架常见类型▏自动化测试就交给软件测评机构
Analysis of common storage types and FTP active and passive modes