计数排序
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Description

#include <cstdio> #include <cstring> using namespace std; const int maxn=10000000; const int maxs=10000; int n; unsigned a[maxn],b[maxn],res[maxn],ord[maxn]; unsigned cnt[maxs+1]; int main() { scanf("%d",&n); for(int i=0;i<n;++i) scanf("%d%d",&a[i],&b[i]); memset(cnt,0,sizeof(cnt)); for(int i=0;i<n;++i) ______(1)______;//利用cnt数组统计数量 for(int i=0;i<maxs;i++) cnt[i+1]+=cnt[i]; for(int i=0;i<n;i++) ______(2)_______;//记录初步排序结果 memset(cnt,0,sizeof(cnt)); for(int i=0;i<n;++i) ______(3)_______;//利用cnt数组统计数量 for(int i=0;i<maxs;i++) cnt[i+1]+=cnt[i]; for(int i=n-1;i>=0;i--) ______(4)_______;//记录最终排序结果 for(int i=0;i<n;i++) { printf("%d %d\n",_______(5)_______); }}
![]()
Output Format
3 3 4 2 4 3 3
2 4
3 3
3 4
Source
排序2023龙游秋学期周六第7-8次课1125
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 8
- 开始于
- 2023-11-25 9:00
- 结束于
- 2023-12-3 20:00
- 持续时间
- 203 小时
- 主持人
- 参赛人数
- 6