BZOJ 2104 K-th Number
来源:互联网 发布:淘宝用别人身份证开店 编辑:程序博客网 时间:2024/06/14 02:42
题目大意:
求区间内第k小的数。
解题思路:
据说是主席树裸题,也可以用归并树划分树来搞。
然而我这么弱怎么可能会呢……
算了算复杂度和POJ的机器速度,YY了半天,写个模拟,卡时过了。
#include<cstdio>struct node{int id,x;}a[100000];int cmp(void const*p,void const*q){return (*(struct node*)p).x>(*(struct node*)q).x?1:-1;}int main(){int n,m,x,y,k;while (~scanf("%d%d",&n,&m)){for (int i=0;i<n;i++){scanf("%d",&a[i].x);a[i].id=i;}qsort(a,n,sizeof(a[0]),cmp);for (int i=0;i<m;i++){scanf("%d%d%d",&x,&y,&k);x--, y--;for (int j=0;j<n;j++){if (a[j].id>=x && a[j].id<=y) k--;if (!k){printf("%d\n",a[j].x);break;}}}}return 0;}
0 0
- BZOJ 2104 K-th Number
- 2104 -- K-th Number
- poj 2104 K-th Number
- poj 2104 K-th Number
- Poj 2104 K-th Number
- POJ-2104-K-th Number
- PKU 2104 K-th Number
- POJ 2104 K-th Number
- POJ-2104-K-th Number
- POJ 2104 K-th Number
- POJ 2104 K-th Number
- POJ 2104 K-th Number
- PKU-2104-K-th Number
- POJ 2104 K-th Number
- POJ 2104 K-th Number
- poj-2104 K-th Number
- POJ 2104 K-th Number
- 【POJ 2104】K-th Number
- 程序员面试中常见10大算法汇总
- bzoj1721 [Usaco2006 Mar]Ski Lift 缆车支柱(dp)
- Java二叉排序树
- iOS URI跳转方式地图导航的代码实践
- 从商用到家庭 服务机器人产业将爆发?
- BZOJ 2104 K-th Number
- Qt 学习之路 2(2):Qt 简介 笔记
- NOIP2010 机器翻译 题解
- iOS开发-OC-Foundation框架
- 【HNOI 模拟】Axonometric Projection
- C++ 单例模式详解
- [leetcode]Isomorphic Strings C语言
- Android 源码下载
- nyoj-1071 不可以!【水】