洛谷 1168 中位数
来源:互联网 发布:软件代理合同范本 编辑:程序博客网 时间:2024/06/06 01:03
#include<bits/stdc++.h>using namespace std;int n, sum1, sum2;priority_queue<int, vector<int>, greater<int> > q2;priority_queue<int> q1;int main(){ scanf("%d", &n); for(int i = 1, x; i <= n; i++){ scanf("%d", &x); if(!sum1){ sum1++; printf("%d\n", x); q1.push(x); continue; } if(sum1 == sum2){ sum1++; int bi = q2.top(); if(bi >= x){ q1.push(x); printf("%d\n", q1.top()); } else{ int bi = q2.top(); printf("%d\n", bi); q1.push(bi); q2.pop(); q2.push(x); } } else if(sum1 == sum2 + 1){ sum2++; int sm = q1.top(); if(sm >= x){ q2.push(sm); q1.pop(); q1.push(x); } else q2.push(x); } } return 0;}
阅读全文
0 0
- 【洛谷 1168】中位数
- 洛谷 1168 中位数
- 洛谷 中位数
- |洛谷|堆|P1168 中位数
- 洛谷 P1168 中位数
- 洛谷 P1168 中位数
- 洛谷P1168 中位数
- 【洛谷】P1627 中位数
- 洛谷P1168 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 中位数
- 使用python builtwith模块分析识别网站开发技术
- 基于Baidu Map InfoWindow的消息交互(失败案例)
- c++中的类模板
- IIS 重定向配置
- H-Updating a Dictionary (模拟)
- 洛谷 1168 中位数
- 输入框优化
- java.lang.IllegalArgumentException: Comparison method violates its general contract!
- ie11下时间控件显示NaN的问题
- Gradle4.0转换Spring源码为eclipse时出现的问题
- easyui中window窗口自定义重新分装,用于iframe子页面弹框,解决多页面共用同一弹框页面问题
- 常见类---Date类,SimpleDateFormat类
- Oracle官网所有JDK及JRE历史版本下载地址
- js分页插件