#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=1e6+,M=4e6+,inf=1e9+,mod=1e9+;
const ll INF=1e18+;
struct is
{
int x;
int pos;
}a[N];
int cmp1(is a,is b)
{
if(a.x!=b.x)
return a.x<b.x;
return a.pos<b.pos;
}
int cmp2(is a,is b)
{
if(a.x!=b.x)
return a.x>b.x;
return a.pos>b.pos;
}
int cmp3(is a,is b)
{
return a.pos>b.pos;
}
int cmp4(is a,is b)
{
return a.pos<b.pos;
}
int main()
{
int n,k1,k2,cas=;
while(~scanf("%d%d%d",&n,&k1,&k2))
{
if(n==&&k1==&&k2==)
break;
for(int i=;i<=n;i++)
scanf("%d",&a[i].x),a[i].pos=i;
sort(a+,a+n+,cmp1);
sort(a+,a+k1+,cmp4);
printf("Case %d\n",cas++);
for(int i=;i<=k1;i++)
printf("%d%c",a[i].pos,(i!=k1)?' ':'\n');
sort(a+,a+n+,cmp2);
sort(a+,a+k2+,cmp3);
for(int i=;i<=k2;i++)
printf("%d%c",a[i].pos,(i!=k2)?' ':'\n');
}
return ;
}

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Problem Description
Buy low, sell high. That is what one should do to make profit in the stock market (we will ignore short selling here). Of course, no one can tell the price of a stock in the future, so it is difficult to know exactly when to buy and sell and how much profit one can make by repeatedly buying and selling a stock.

But if you do have the history of price of a stock for the last n days, it is certainly possible to determine the maximum profit that could have been made. Instead, we are interested in finding the k1 lowest prices and k2 highest prices in the history.

 
Input
The input consists of a number of cases. The first line of each case starts with positive integers n, k1, and k2 on a line (n <= 1,000,000, k1 + k2 <= n, k1, k2 <= 100). The next line contains integers giving the prices of a stock in the last n days: the i-th integer (1 <= i <= n) gives the stock price on day i. The stock prices are non-negative. The input is terminated by n = k1 = k2 = 0, and that case should not be processed.
 
Output
For each case, produce three lines of output. The first line contains the case number (starting from 1) on one line. The second line specifies the days on which the k1 lowest stock prices occur. The days are sorted in ascending order. The third line specifies the days on which the k2 highest stock prices occur, and the days sorted in descending order. The entries in each list should be separated by a single space. If there are multiple correct lists for the lowest prices, choose the lexicographically smallest list. If there are multiple correct lists for the highest prices, choose the lexicographically largest list.
 
Sample Input
10 3 2
1 2 3 4 5 6 7 8 9 10
10 3 2
10 9 8 7 6 5 4 3 2 1
0 0 0
 
Sample Output
Case 1
1 2 3
10 9
Case 2
8 9 10
2 1
 
Source

hdu 4163 Stock Prices 水的更多相关文章

  1. hdu 4163 Stock Prices 花式排序

    Stock Prices Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  2. hdu 4940 数据太水...

    http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...

  3. hdu 1106:排序(水题,字符串处理 + 排序)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...

  4. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

  5. HDU 4813 Hard Code 水题

    Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  6. HDU 4593 H - Robot 水题

    H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  7. HDOJ/HDU 2560 Buildings(嗯~水题)

    Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...

  8. HDOJ(HDU) 1859 最小长方形(水题、、)

    Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...

  9. hdu 5753 Permutation Bo 水题

    Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

随机推荐

  1. flexbox in IE (10+ and 9 and 8)

    .parent { display: -webkit-box !important; display: -moz-box !important; display: -ms-flexbox !impor ...

  2. zabbix用自带模板监控mysql

    本身zabbix-agent没有提供对mysql监控的key,所以需要自定义key来应用这个模板 默认的模板有以下三类 mysql.status[var] mysql.ping mysql.versi ...

  3. 【JQGRID DOCUMENTATION】.学习笔记.6.Editing:Common Rules

    1 公共编辑属性 要在grid中显示数据的一个关键原因是能简单快速地编辑它.jgGrid提供三种编辑方式: cell editing:编辑指定cell inline editing:编辑同一行的几个c ...

  4. golang的helloworld

    新建源码文件hello.go mkdir -p /work/goTest/ cd /work/goTest/ vim hello.go 编码hello.go文件: package main impor ...

  5. cocospod 安装和使用

    一 ruby 安装 要安装coocspod 首先需要安装ruby,可以先安装xcode,在安装macport 下载地址,最后执行命令 port install ruby 二.安装CocoaPods 1 ...

  6. ectouch第八讲 之模板内容修改

    前台:1.前台页面logo代码[ 文件位置:\mobile\themes\default\index.dwt] <div style="text-align: center;paddi ...

  7. Shell—学习之心得

    由于项目要招聘需要有经验shell开发人员(awk编程),而作为技术面试官(暂时)的我对shell编程不太熟:当然以前也写过一些shell脚本来满足项目的需求—备份环境,数据库(逻辑).假如只是针对a ...

  8. mysql 关联条件与查询(过滤)条件

    mysql用outer join时 on 后边只是关联条件,有时可能会查出无用的记录, 需用where查询条件过滤 五欧诺个的数据. 记录一下

  9. cocos2dx win打包apk

    1.配置环境(未完) 2. eclipse 导入项目之后配置 Builder新建两个.一个是ndk目录下的 ndk-build.cmd  ,一个是自己写的build_native.bat 拷贝资源的 ...

  10. android -- 蓝牙 bluetooth (五)接电话与听音乐

    1.蓝牙耳机接听电话         这个就对应HFP(Hands-freeProfile),Free your Hand,蓝牙的初衷之一.先来看这个功能的场景,手机来电,手机与蓝牙耳机已连接,这时会 ...