hdu 4163 Stock Prices 水
#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)
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.
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
1 2 3
10 9
Case 2
8 9 10
2 1
hdu 4163 Stock Prices 水的更多相关文章
- hdu 4163 Stock Prices 花式排序
Stock Prices Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu 4940 数据太水...
http://acm.hdu.edu.cn/showproblem.php?pid=4940 给出一个有向强连通图,每条边有两个值分别是破坏该边的代价和把该边建成无向边的代价(建立无向边的前提是删除该 ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- HDU 4950 Monster (水题)
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...
- HDU 4813 Hard Code 水题
Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- HDU 4593 H - Robot 水题
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- HDOJ/HDU 2560 Buildings(嗯~水题)
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...
- HDOJ(HDU) 1859 最小长方形(水题、、)
Problem Description 给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内.长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内 ...
- hdu 5753 Permutation Bo 水题
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...
随机推荐
- linux设备驱动归纳总结(二):模块的相关基础概念【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-59415.html linux设备驱动归纳总结(二):模块的相关基础概念 系统平台:Ubuntu 10 ...
- Zabbix中使用ICMP ping来判断主机是否存活的问题
上一节配置了Simple check,现在来通过Simple check 用ICMP ping来监控充节点运行情况.Zabbix使用fping处理ICMP ping的请求,需要安装fping程序,安装 ...
- Java中的线程同步机制
一.首先为什么线程需要同步? 1.多线程安全问题的原因 A:有多线程环境 B:有共享数据 C:有多条语句操作共享数据 2. //未完待续后面会继续更新
- php curl向远程服务器上传文件
<?php /** * test.php: */ header('content-type:text/html;charset=utf8'); $ch = curl_init(); //加@符号 ...
- 【转】Android WebView 播放视频总结
今天发现 WebView里播放优酷的视频点击播放按钮后没反应,于是看官方文档和搜索解决,下面是我在别人基础上做的补充: android webView 无法播放视频,无法暂停,继续播放视频问题,无 ...
- poj3342 Party at Hali-Bula
树形dp题,状态转移方程应该很好推,但一定要细心. http://poj.org/problem?id=3342 #include <cstdio> #include <cstrin ...
- 【转】探索C++的秘密之详解extern
本文转自:http://i.cnblogs.com/EditPosts.aspx?opt=1 时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus extern "C ...
- Linux 文件操作总结
http://blog.163.com/he_junwei/blog/static/19793764620152592737741/ ioctl?? lseek?? 文件是linux中的一个重要概念. ...
- JAVA基础知识之网络编程——-使用Proxy创建连接
在前面的HTTP网络通信的例子中,使用了URLConnection conn = url.openConnection();连接网络, 如果改用URLConnection conn = url.ope ...
- Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined) A
Description You are given names of two days of the week. Please, determine whether it is possible th ...