提交记录 28102


用户 题目 状态 得分 用时 内存 语言 代码长度
SR_AKIOI test. 自定义测试 Accepted 100 44.49 us 60 KB C++ 637 B
提交时间 评测时间
2025-05-23 21:07:02 2025-05-23 21:07:04
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define int long long
#define inf (1ll << 62)
constexpr int N=1e5+7;
int m[N];
int tot;
int n;
void repaira(int x){
	if(x==1||m[x/2]<m[x]) return;
	swap(m[x],m[x/2]);
	repaira(x/2);
}
void repairb(int x){
	if(x*2>tot) return ;
	int tmp=x*2;
	if(x*2+1<=tot) tmp=(m[x*2]<m[x*2+1]?x*2:x*2+1);
	if(m[x]>m[tmp]){
		swap(m[x],m[tmp]);
		repairb(tmp);
	}
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m[++tot];
		repaira(tot);
	}
	for(int i=1;i<=n;i++){
		cout<<m[1]<<" ";
		swap(m[1],m[tot--]);
		repairb(1);
	}
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #144.49 us60 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-06-01 22:43:15 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠