蓝桥杯-卡java排序

问题描述

本题是一道针对 Java 中 Arrays.sort 的题目,因此只有一个数据,该数据可以把 int 类型的数组在使用 Arrays.sort 后卡成 O(n2)O(n2)。

给定一个有 nn 个正整数的序列 aa,你需要将其升序排序后输出。

输入格式

第一行输入一个正整数 nn。(n=2×105)(n=2×105)

第二行输入 nn 个正整数 aiai​。(1≤i≤n,1≤ai≤n)(1≤i≤n,1≤ai​≤n)。

输出格式

输出 nn 个正整数,为升序排列后的序列 aa。

样例输入

6
1 3 2 3 2 5

样例输出

1 2 2 3 3 5

说明

样例只是为了补充说明,和实际测试数据并不一致。

运行限制

语言 最大运行时间 最大运行内存
C++ 1s 256M
C 1s 256M
Java 2s 256M
Python3 3s 256M
PyPy3 3s 256M
Go 3s 256M
JavaScript 3s 256M
#include
#include
#include
using namespace std;
int main()
{
    int n;
    cin>>n;
    vectora(n);
    for(int i=0;i>a[i];
    sort(a.begin(),a.end());
    for(int i=0;i

你可能感兴趣的:(蓝桥杯,c++,算法)