博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 5249 KPI(set+queue+二分查找)(转载)
阅读量:4138 次
发布时间:2019-05-25

本文共 2352 字,大约阅读时间需要 7 分钟。

KPI

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1206 Accepted Submission(s): 503
Problem Description
你工作以后, KPI 就是你的全部了. 我开发了一个服务,取得了很大的知名度。数十亿的请求被推到一个大管道后同时服务从管头拉取请求。让我们来定义每个请求都有一个重要值。我的KPI是由当前管道内请求的重要值的中间值来计算。现在给你服务记录,有时我想知道当前管道内请求的重要值得中间值。
Input
有大约100组数据。
每组数据第一行有一个
n(1n10000) ,代表服务记录数。
接下来有n行,每一行有3种形式
"in x": 代表重要值为
x(0x109) 的请求被推进管道。
"out": 代表服务拉取了管道头部的请求。
"query: 代表我想知道当前管道内请求重要值的中间值. 那就是说,如果当前管道内有m条请求, 我想知道,升序排序后第
floor(m/2)+1th 条请求的重要值.
为了让题目简单,所有的x都不同,并且如果管道内没有值,就不会有"out"和"query"操作。
Output
对于每组数据,先输出一行
Case #i:
然后每一次"query",输出当前管道内重要值的中间值。
Sample Input
6in 874queryoutin 24622in 12194query
Sample Output
Case #1:87424622
Source

/*超时 #include 
#include
#include
using namespace std;const int N=10000+10;int a[N],b[N];int len,now;string s;int c;int main(){ int n,t=1; while(cin>>n){ len=0; now=0; cout<<"Case #"<
<<":"<
>s; if(s=="in"){ cin>>c; a[len++]=c; }else if(s=="out"){ now++; }else if(s=="query"){ int ll=0; for(int i=now;i
#include
#include
using namespace std;const int N=10000+10;int a[N],b[N];int len,now;string s;int c;int main(){ int n,t=1; while(scanf("%d",&n)==1){ len=0; now=0; printf("Case #%d:\n",t++); while(n--){ cin>>s; if(s=="in"){ scanf("%d",&c); a[len++]=c; }else if(s=="out"){ now++; }else if(s=="query"){ int ll=0; for(int i=now;i
#include
#include
#include
#include
using namespace std;const int maxn=10000+10;int num[maxn];int bcnt;int add(int t){ int i; int flash=0,k; if(bcnt==0) { num[++bcnt]=t; return 0; } if(num[bcnt]
Q; bcnt=0; printf("Case #%d:\n",d++); for(i=1;i<=n;i++) { scanf("%s",str); if(str[0]=='i') { scanf("%d",&a); Q.push(a); add(a); } else if(str[0]=='q') { printf("%d\n",num[(bcnt/2)+1]); } else if(str[0]=='o') { int x=Q.front(); Q.pop(); fun(x); } } } return 0;}*//*赛后:*/#include
#include
#include
#include
#include
#include
using namespace std;set
stL,stR;//set
::iterator it;queue
Q;int main(){ int n,x,t=0; char str[20]; while(~scanf("%d",&n)) { stL.clear(); stR.clear(); while(!Q.empty())Q.pop(); printf("Case #%d:\n",++t); while(n--) { scanf("%s",str); if(str[0]=='i') { scanf("%d",&x); Q.push(x); if(*stR.begin()
stR.size()) { stR.insert(*(--stL.end())); stL.erase(--stL.end()); } while(stL.size()+1

你可能感兴趣的文章
python使用dpkt分析wireshak报文(Modbus规约)
查看>>
css中的IFC
查看>>
CentOS 6.5下 mysql用户root登录不了
查看>>
windows + tomcat 部署web服务 http 改为https访问方法
查看>>
Windows系统下Apache 服务器启动以及过程中产生问题的解决办法
查看>>
Oracle服务说明
查看>>
异常收集(三):Missing artifact com.oracle:ojdbc6:jar:1.0 两种解决方案
查看>>
异常收集(四):Plugin execution not covered by lifecycle configuration
查看>>
异常收集(五):Io 异常: The Network Adapter could not establish the connection
查看>>
JSP中的转义字符
查看>>
SQLException: The user specified as a definer ('root'@'%') does not exist
查看>>
Linux 操作指令收集
查看>>
CentOS 7下卸载MySQL方式(转)
查看>>
CentOS7 安装MySQL 5.6.43
查看>>
使用Java 导入/导出 Excel ----Jakarta POI
查看>>
本地tomcat 服务器内存不足
查看>>
IntelliJ IDAE 2018.2 汉化
查看>>
基于S5PV210的uboot移植中遇到的若干问题记录(一)DM9000网卡移植
查看>>
Openwrt源码下载与编译
查看>>
我和ip_conntrack不得不说的一些事
查看>>