当前位置:网站首页>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;
}
边栏推荐
- 故障分析 | MySQL 耗尽主机内存一例分析
- Follow the mouse's angle and keyboard events
- Y a - t - il des cas où sqlcdc surveille plusieurs tables et les associe à une autre? Tout fonctionne dans MySQL
- 【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)
- Thinking on Architecture Design (under continuous updating)
- 技术管理进阶——什么是管理者之体力、脑力、心力
- 好用的 JS 脚本
- 数据准备工作
- MySQL winter vacation self-study 2022 11 (9)
- 一个复制也能玩出花来
猜你喜欢
故障分析 | MySQL 耗尽主机内存一例分析
Sword finger offer 29 Print matrix clockwise
LeetCode 103. Binary tree zigzag level order transverse - Binary Tree Series Question 5
全国大学生信息安全赛创新实践赛初赛---misc(永恒的夜)
[untitled] a query SQL execution process in the database
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
一个复制也能玩出花来
构建库函数的雏形——参照野火的手册
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 11
Network Security Learning - Web vulnerabilities (Part 1)
随机推荐
在GBase 8c数据库中使用自带工具检查健康状态时,需要注意什么?
力扣今日题-729. 我的日程安排表 I
Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
ReferenceError: primordials is not defined错误解决
Bigder:34/100 面试感觉挺好的,没有收到录取
事故指标统计
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 18
DDoS "fire drill" service urges companies to be prepared
inherited constructors
Universal crud interface
Sword finger offer 30 Stack containing min function
"Hands on learning in depth" Chapter 2 - preparatory knowledge_ 2.3 linear algebra_ Learning thinking and exercise answers
Shell script updates stored procedure to database
HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
淘宝焦点图布局实战
解决:AttributeError: ‘str‘ object has no attribute ‘decode‘
Is there a case where sqlcdc monitors multiple tables and then associates them to sink to another table? All operations in MySQL
RobotFramework入门(一)简要介绍及使用
2345 file shredding, powerful file deletion tool, unbound pure extract version
Patch NTP server at the beginning of DDoS counterattack