原题链接:http://codeforces.com/contest/572/problem/B

题意

很迷,自行看题。

题解

看懂题就会做了

代码

#include<iostream>
#include<cstring>
#include<algorithm>
#define MAX_N 100005
using namespace std; int n,s; struct exchange {
public:
bool ty;
int p, q;
double sp; exchange(bool t, int pp, int qq) : ty(t), p(pp), q(qq), sp((double) p / q) { } exchange() { }
}; bool cmp(exchange a,exchange b) {
if (a.ty == b.ty) {
if (a.ty)return a.p > b.p;
else return a.p < b.p;
}
return a.ty < b.ty;
} int buy[MAX_N];
int sell[MAX_N]; exchange E0[MAX_N],E1[MAX_N];
int tot0,tot1; bool cmp0(exchange a,exchange b){
return a.p>b.p;
} int main(){
cin.sync_with_stdio(false);
cin>>n>>s;
for(int i=;i<n;i++){
char t;
int p,q;
cin>>t>>p>>q;
if(t=='B')buy[p]+=q;
else sell[p]+=q;
}
for(int i=;i<MAX_N;i++)
if(sell[i])
E0[tot0++]=exchange(,i,sell[i]);
for(int i=;i<MAX_N;i++)
if(buy[i])
E1[tot1++]=exchange(,i,buy[i]);
sort(E0,E0+tot0,cmp);
sort(E1,E1+tot1,cmp);
sort(E0,E0+min(s,tot0),cmp0);
sort(E1,E1+min(s,tot1),cmp0);
for(int i=;i<min(s,tot0);i++)cout<<"S "<<E0[i].p<<" "<<E0[i].q<<endl;
for(int i=;i<min(s,tot1);i++)cout<<"B "<<E1[i].p<<" "<<E1[i].q<<endl;
return ;
}

Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) Order Book 模拟的更多相关文章

  1. Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) Minimization dp

    原题链接:http://codeforces.com/contest/572/problem/D 题意 给你个数组A和n,k,问你排列A后,下面的最小值是多少. 题解 先排个序,要填充像1,1+k,1 ...

  2. Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) Array 模拟

    题目链接:http://codeforces.com/contest/572/problem/A 题意 就给你两个数组,问你能不能从A数组中取出k个,B数组中取出m个,使得这k个都大于这m个. 题解 ...

  3. Codeforces Round #539&#542&#543&#545 (Div. 1) 简要题解

    Codeforces Round #539 (Div. 1) A. Sasha and a Bit of Relax description 给一个序列\(a_i\),求有多少长度为偶数的区间\([l ...

  4. Codeforces Round VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM 暴力出奇迹!

    VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Lim ...

  5. Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 题解

    Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 题目链接:https://codeforces.com/contest/1130 ...

  6. Codeforces Round #317 (div 2)

    Problem A Arrays 思路:水一水. #include<bits/stdc++.h> using namespace std; ; int n1,n2,k,m,a[N],b[N ...

  7. Codeforces Round #317 (Div. 2) D Minimization (贪心+dp)

    D. Minimization time limit per test  2 seconds memory limit per test  256 megabytes input  standard ...

  8. Codeforces Round #317 (Div. 2) C Lengthening Sticks (组合,数学)

    一个合法的三角形的充要条件是a<b+c,其中a为最长的一边,可以考虑找出所有不满足的情况然后用总方案减去不合法的情况. 对于一个给定的总长度tl(一定要分完,因为是枚举tl,不分配的长度已经考虑 ...

  9. Codeforces Round #237 (Div. 2) B题模拟题

    链接:http://codeforces.com/contest/404/problem/B B. Marathon time limit per test 1 second memory limit ...

随机推荐

  1. Python基础:字符串(string)

    字符串的常用操作 字符串与数组一样,支持索引操作.切片与遍历 索引.切片操作: name = 'jason' name[0] 'j' name[1:3] 'as' 遍历: for char in na ...

  2. 多本Python极速入门最佳书籍,不可错过的Python学习资料!

    Python作为现在很热门的一门编程语言,介于Python的友好,许多的初学者都将其作为首选,为了帮助大家更好的学习Python,我筛选了2年内优秀的python书籍,个别经典的书籍扩展到5年内.   ...

  3. Mysql之查看数据库版本

    Mysql版本: 登入数据库的时候: select @@version; select version(); mysql> select @@version; +-----------+ | @ ...

  4. [转] NGINX宏观手记

    前言 任何一个工具都有它的灵魂所在,作为一个PHP程序员,我们可能仅仅使用了它的一小部分,这篇文章让你更加了解Nginx,本章大多都是总结.翻译.整理 ,希望你可以知道nginx不仅仅是PHP的附属品 ...

  5. loj2032 「SDOI2016」游戏

    做了 [JSOI2008]Blue Mary开公司 以后发现这 tm 不就是个傻逼树剖+李超线段树吗,做了以后发现我才是傻逼--树剖竟然写错了--这题是我目前写过最长的代码了qwq #include ...

  6. stl vector 类

    目录 [-]说明构造方法例子vector 类中定义了4中种构造函数: · 默认构造函数,构造一个初始长度为0的空向量,如:vector<int> v1; · 带有单个整形参数的构造函数,此 ...

  7. Leetcode 452.用最少数量的箭引爆气球

    用最少数量的箭引爆气球 在二维空间中有许多球形的气球.对于每个气球,提供的输入是水平方向上,气球直径的开始和结束坐标.由于它是水平的,所以y坐标并不重要,因此只要知道开始和结束的x坐标就足够了.开始坐 ...

  8. Debian下无root权限使用Python访问Oracle

    这篇文章的起因是,在公司的服务器上没有root权限,但是需要使用 Python 访问 Oracle,而不管是使用 pip 安装组件还是安装 Oracle 的 client,都需要相应权限.本文即解决该 ...

  9. linux 下java jar包的方法

      test.java 和 example.jar 在同一目录:并且test.java引用了example.jar 首先编译test.java: javac -cp example.jar test. ...

  10. java jstl标签

    转自:http://blog.csdn.net/liushuijinger/article/details/9143793 JSTL(JSP Standard Tag Library ,JSP标准标签 ...