bzoj 4096: [Usaco2013 dec]Milk Scheduling 贪心
来源:互联网 发布:2017年电视直播软件 编辑:程序博客网 时间:2024/05/29 19:32
→题目链接←
从后往前扫deadline,每次找到一个符合条件并且贡献最大的,就算进答案
代码:
#include<iostream>#include<vector>#include<queue>#include<cstdio>#include<string>#include<cstring>using namespace std;struct node{int g,d;friend bool operator < (node a,node b){if(a.d==b.d)return a.g<b.g;return a.d<b.d;}};int n;int ans=0;node a[10010];int main(){scanf("%d",&n);for(int i=1; i<=n; i++){int x,y;scanf("%d%d",&a[i].g,&a[i].d);}for(int i=n; i>0; i--){int x=0;for(int j=1; j<=n; j++)if(a[j].g>a[x].g && a[j].d>=i)x=j;if(x)ans+=a[x].g,a[x].g=0;}printf("%d\n",ans);return 0;}
阅读全文
0 0
- bzoj 4096: [Usaco2013 dec]Milk Scheduling 贪心
- [BZOJ 4096] Usaco2013 dec Milk Scheduling · 贪心
- BZOJ 4093: [Usaco2013 Dec]Vacation Planning
- bzoj 1717: [Usaco2006 Dec] Milk Patterns
- BZOJ 4094 Usaco2013 Dec Optimal Milking 线段树
- BZOJ 4094: [Usaco2013 Dec]Optimal Milking 线段树
- bzoj 4094: [Usaco2013 Dec]Optimal Milking 线段树
- BZOJ 4094 [Usaco2013 Dec]Optimal Milking 线段树
- bzoj 4094: [Usaco2013 Dec]Optimal Milking 线段树
- 洛谷P3093 [USACO13DEC]牛奶调度Milk Scheduling(贪心)
- bzoj 1717 [Usaco2006 Dec]Milk Patterns 产奶的模式
- [BZOJ]1717 [Usaco2006 Dec]Milk Patterns 二分答案
- [BZOJ4094] [Usaco2013 Dec]Optimal Milking
- SOJ 12261 Milk Scheduling
- Sicily 13983. Milk Scheduling
- [Usaco2006 Dec]Milk Patterns
- bzoj 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式(后缀数组)
- BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 二分答案 哈希/后缀数组
- Vtiger CRM (PHP) 外部访问TTFB waiting 时间过长
- Android自定义控件中的一个动画细节
- 短信通知栏
- Java问题思考
- 第三章、ReactNative页面跳转
- bzoj 4096: [Usaco2013 dec]Milk Scheduling 贪心
- robot framework找不到元素定位
- emWin 2天速成实例教程002_多个页面窗口切换
- Noip2014 Day1 T1 生活大爆炸版石头剪刀布
- CenOS Linux 安装Sublime Text
- Getting Start(框架,网络,客户端,服务器,消息(含外部),服务,集群)
- 【ios控件】UIScrollView 事件说明
- 奇怪的表达式求值--网易2017春招实习笔试编程题8
- Struts2框架入门