Codeforces 725D
来源:互联网 发布:淘宝宝贝库存在哪设置 编辑:程序博客网 时间:2024/06/08 17:46
把所有的队伍分成两种,一种是气球数多于自己的(当前排名比自己高的),一种是气球数不大于自己的
首先求出初始排名,然后肯定是要每次把气球给当前排名高于自己队的队伍(助人飞升),显然可以用堆维护,每次选出(t-w+1)最小的队伍
然后自己队伍的气球会减少,刷新自己的排名刷新答案并且把气球数多于自己队伍的队伍放入堆中
#include<cstdio>#include<algorithm>#include<queue>#define N 300005#define LL long long#define RG registerusing namespace std;inline LL read(){ LL a=0;int f=1;char c=getchar(); while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();} while(c>='0'&&c<='9'){a=a*10+c-'0';c=getchar();} return a*f;}struct node{ LL t,w; bool operator < (const node &c) const {return t>c.t;}}team[N];LL n,t,w;int ans,_d;priority_queue<LL,vector<LL>,greater<LL> >heap;int main(){ n=read()-1; int i; t=read(),w=read(); for(i=1;i<=n;++i) team[i].t=read(),team[i].w=read(); sort(team+1,team+n+1); i=1; while(i<=n&&team[i].t>t) heap.push(team[i].w-team[i].t+1),++i; ans=i; while(!heap.empty()) { LL x=heap.top();heap.pop(); if(x>t) break; t-=x;++_d; while(i<=n&&team[i].t>t) heap.push(team[i].w-team[i].t+1),++i; ans=min(ans,i-_d); } printf("%d\n",ans); return 0;}
阅读全文
0 0
- Codeforces 725D
- Codeforces 725D By Assassin
- Codeforces 725D Contest Balloons
- codeforces 725D Contest Balloons
- Codeforces 725D Contest Balloons
- 【37.74%】【codeforces 725D】Contest Balloons
- codeforces 725D Conteset Balloons 贪心
- Codeforces 725D[Contest Balloons]【贪心】
- CodeForces 617D CodeForces 617D
- CodeForces 101D
- CodeForces 103D
- CodeForces 222D Olympiad
- codeforces 242d
- CodeForces 111D
- 【codeforces】3D
- CodeForces 127D Password
- codeforces 257D. Sum
- Codeforces 292D
- 读书笔记,软件生存期模型
- U-Boot启动过程完全分析
- Python3之线程Queue实现生产者消费者模型
- 硬件算法__二进制转BCD码
- Mybatis的插件 PageHelper 分页查询使用方法
- Codeforces 725D
- Qt如何配置项目环境
- git 常用指令介绍
- IT/电子专业常见英文词汇
- HTTP的长连接,你不知道的连接。。。
- 欢迎使用CSDN-markdown编辑器
- javascript的表单事件
- iOS 共钥验签 证书验签
- hdu 4283 You Are the One