当前位置:网站首页>CSP numeric sort
CSP numeric sort
2022-07-06 02:39:00 【< WRM>】
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
struct node {
int cunt;
int data;
}a[N];
bool compare(node x,node y) {
if(x.cunt!=y.cunt) {
return x.cunt>y.cunt;
}
return x.data<y.data;
}
int b[N];
int main() {
int n;
scanf("%d",&n);
int x;
memset(b,0,sizeof(b));
for(int i=1;i<=n;i++) {
scanf("%d",&x);
b[x]++;
}
int k=-1;
for(int i=0;i<=1000;i++) {
if(b[i]) {
k++;
a[k].data=i;
a[k].cunt=b[i];
}
}
sort(a,a+k+1,compare);
for(int i=0;i<=k;i++) {
printf("%d %d\n",a[i].data,a[i].cunt);
}
return 0;
}
边栏推荐
- Spherical lens and cylindrical lens
- 729. My schedule I / offer II 106 Bipartite graph
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- 高数_向量代数_单位向量_向量与坐标轴的夹角
- Number conclusion LC skimming review - 1
- [Digital IC manual tearing code] Verilog asynchronous reset synchronous release | topic | principle | design | simulation
- Differences and usage scenarios between TCP and UDP
- Introduction to robotframework (I) brief introduction and use
- Paper notes: graph neural network gat
- Sword finger offer 30 Stack containing min function
猜你喜欢

High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis

PMP practice once a day | don't get lost in the exam -7.5

HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12](/img/b1/926d9b3d7ce9c5104f3e81974eef07.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12

Introduction to robotframework (III) Baidu search of webui automation

力扣今日题-729. 我的日程安排表 I

2022 eye health exhibition, vision rehabilitation exhibition, optometry equipment exhibition, eye care products exhibition, eye mask Exhibition

Easy to use js script

UE4 - how to make a simple TPS role (I) - create a basic role
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9](/img/ed/0edff23fbd3880bc6c9dabd31755ac.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
随机推荐
Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
2022 China eye Expo, Shandong vision prevention and control exhibition, myopia, China myopia correction Exhibition
How to accurately identify master data?
MySQL winter vacation self-study 2022 11 (6)
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
sql表名作为参数传递
MySQL winter vacation self-study 2022 11 (5)
Advanced technology management - what is the physical, mental and mental strength of managers
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
DDoS attacks - are we really at war?
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 7
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
从顶会论文看2022年推荐系统序列建模的趋势
Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
MySQL winter vacation self-study 2022 11 (7)
剑指 Offer 30. 包含min函数的栈
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 23
大厂镜像库
Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
GifCam v7.0 极简GIF动画录制工具中文单文件版