CodeForces #317 (div2) B.Order Book
来源:互联网 发布:注册单和淘宝单的区别 编辑:程序博客网 时间:2024/04/29 05:03
题目大意:
这道题看懂题目就应该会做了……给出两种操作,操作对象相同的操作值进行合并,两种操作,都降序输出,如果操作数小于某个值,则尽可能的输出。
解题思路:
模拟就好了吧……
#include<cstdio>#include<cstring>#include<string>#include<cmath>#include<iostream>#include<algorithm>#include<set>#define LL long long#define db double#define maxn 10000000#define EPS 1e-15#define max(a,b) ((a>b)?(a):(b))#define min(a,b) ((a<b)?(a):(b))using namespace std;int n,m;int buy[100100];int sell[100100];int main(){ while(scanf("%d%d",&n,&m)!=EOF){ memset(buy,0,sizeof(buy)); memset(sell,0,sizeof(sell)); char str[11]; int x,y; for(int i=0;i<n;i++){ scanf("%s%d%d",str,&x,&y); if(strcmp(str,"B") == 0){ buy[x] += y; }else{ sell[x] += y; } } int t = 0; int p = 0; for(int i=0;i<=100000;i++) { if(t<m && sell[i]){ t++; p = i; }else if(t>=m){ break; } } for(int i=p;i>=0;i--){ if(sell[i]){ printf("S %d %d\n",i,sell[i]); t++; } } t = 0; for(int i=100000;i>=0;i--){ if(t<m && buy[i]){ printf("B %d %d\n",i,buy[i]); t++; }else if(t>=m){ break; } } } return 0;}
0 0
- CodeForces #317 (div2) B.Order Book
- B. Order Book(Codeforces Round #317 )
- Codeforces Round #317 B. Order Book
- 【codeforces 572B】Order Book
- 【CodeForces 572B】Order Book(排序)
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) B. Order Book
- Codeforces Round #317 (Div. 2) (572A Arrays,572B Order Book)
- B. Order Book------(Codeforces Round #317 [AimFund Thanks-Round] (Div. 2))
- Codeforces Round #317 (Div. 2) 572B. Order Book 排序+贪心
- Codeforces Round #317 [AimFund Thanks-Round] (Div. 2) B Order Book
- cf#317-B-Order Book-水题
- coderforce 572B Order Book
- codeforces 105 div2 B
- codeforces 148 div2 B
- Codeforces #103 div2 B
- codeforces 257 div2 B
- Codeforces #263 Div2 B
- codeforces #Round354-div2-B
- vbox 安装增强功能 遇到的几个问题的总结
- char *,char **,char a[ ],char *a[]
- Tomcat的配置文件 —— server.xml
- AC自动机 - hdu2222 Keywords Search
- linux修改环境变量
- CodeForces #317 (div2) B.Order Book
- wordpress第一篇
- poj 2931 Building a Space Station <克鲁斯卡尔>
- linux延时函数
- 路径动画
- cglib动态代理和jdk的动态代理
- Android xml实现Button背景图片
- 数据库事务并发有关问题
- 用64行代码实现生产者与消费者模型