zoukankan      html  css  js  c++  java
  • 3110 二叉堆练习3

    3110 二叉堆练习3

     

    时间限制: 3 s
    空间限制: 128000 KB
    题目等级 : 黄金 Gold
     
     
     
     
    题目描述 Description

    给定N(N≤500,000)和N个整数(较有序),将其排序后输出。

    输入描述 Input Description

    N和N个整数

    输出描述 Output Description

    N个整数(升序)

    样例输入 Sample Input

    5

    12 11 10 8 9

    样例输出 Sample Output

    8 9 10 11 12

    数据范围及提示 Data Size & Hint

    对于33%的数据 N≤10000

    对于另外33%的数据 N≤100,000  0≤每个数≤1000

    对于100%的数据 N≤500,000  0≤每个数≤2*10^9

    分类标签 Tags

     1 #include<iostream>
     2 #include<algorithm>
     3 using namespace std;
     4 long long int a[1000001];
     5 int main()
     6 {
     7     int n;
     8     cin>>n;
     9     for(int i=1;i<=n;i++)
    10     {
    11         cin>>a[i];
    12         push_heap(a+1,a+i+1,greater<int>());
    13     }
    14     int m=n;
    15     for(int i=1;i<=n;i++)
    16     {
    17         int d=a[1];
    18         cout<<d<<" ";
    19         pop_heap(a+1,a+m+1,greater<int>());
    20         m--;
    21     }
    22     return 0;
    23  } 
  • 相关阅读:
    ps入门
    ls命名 | Linux统计文件夹内的文件个数
    python打包成可执行文件
    装饰器
    poj 2752 Seek the Name, Seek the Fame
    字符串最大值
    次小生成树
    Selecting Courses
    poj 3461 Oulipo
    poj 2406 Power Strings
  • 原文地址:https://www.cnblogs.com/zwfymqz/p/6653627.html
Copyright © 2011-2022 走看看