Codeforces Round #401 (Div. 2)Hanoi Factory CDQ分治
来源:互联网 发布:烟机二件套 知乎 编辑:程序博客网 时间:2024/04/29 22:25
虽然这场CF最后还是AK了,但是打得及其猥琐。
开场十分钟发现自己外卖下单八点不小心选成十点,花了一吨时间退单,输在起跑线……
不过手速还行,慢慢追上来了,留了70分钟写最后一题,应该是一个线段树就没了的题目。
觉得cdq写的短,就硬上了。
然后排序大于小于号弄错了一万个,2500分的题被我打剩1200分
#include <bits/stdc++.h>#define N 2000050using namespace std;typedef long long LL;int n,m;LL ans;inline int rd() { int r; scanf("%d",&r); return r; }struct Monster{ int l,r; LL v,ans; }Q[N];inline void ut(LL &x,LL y) { x = max(x,y); }bool cmp(Monster p1,Monster p2) { return p1.r == p2.r ? p1.l > p2.l : p1.r > p2.r;}bool cmp2(Monster p1,Monster p2) { return p1.l > p2.l;}void solve(int l,int r) { if (l >= r) return ; int mid = (l + r) >> 1; solve(l,mid); sort(Q+l,Q+mid+1,cmp2); int T = mid+1; LL cur = 0LL; for (int _=r;_>=mid+1;_--) { while (T-1 >= l && Q[T-1].l < Q[_].r) ut(cur , Q[T-1].ans) , T--; ut(Q[_].ans,cur+Q[_].v); } solve(mid+1,r);}int main() { n = rd(); for (int i=1;i<=n;i++) Q[i].l = rd() , Q[i].r = rd() , Q[i].ans = Q[i].v = rd(); sort(Q+1,Q+n+1,cmp); solve(1,n); for (int i=1;i<=n;i++) ut(ans,Q[i].ans); cout << ans << endl; return 0;}
0 0
- Codeforces Round #401 (Div. 2)Hanoi Factory CDQ分治
- Codeforces Round #401 (Div. 2) E. Hanoi Factory 贪心+栈
- Codeforces Round #401 (Div. 2):E. Hanoi Factory
- Codeforces Round #401(Div. 2)E. Hanoi Factory【贪心+栈】
- Codeforces Round #401 (Div. 2 )E. Hanoi Factory
- Codeforces Round #401 (Div. 2) E. Hanoi Factory 贪心+栈
- Codeforces Round #401 (Div. 2)E. Hanoi Factory(离散化+线段树)
- Codeforces Round #431 (Div. 2) (Codeforces 850C) E. Goodbye Souvenir cdq分治
- DP Codeforces Round 401#div2 E.Hanoi Factory
- Codeforces Round #431 (Div. 2) E. Goodbye Souvenir CDQ分治 或 离散化 线段树套树状数组
- Codeforces Round #276 (Div. 2) Factory
- Codeforces Round #230 (Div. 2) D - Tower of Hanoi
- Codeforces Round #276 (Div. 2)A. Factory 数学+规律
- Codeforces Round #240 (Div. 2) E分治算法探究1
- Codeforces Round #256 (Div. 2/C)/Codeforces448C_Painting Fence(分治)
- Codeforces Round #230 (Div. 2) C. Blocked Points D. Tower of Hanoi
- Codeforces Round #230 (Div. 2) C. Blocked Points D. Tower of Hanoi
- Codeforces Round #230 (Div. 2) D. Tower of Hanoi (加强版汉诺塔,DP)
- Redis 入门
- SpringMVC支付宝支付即时到账
- javaweb 用户未登入,只能访问系统默认首页。
- 重新认识MIME类型
- 【HPU 1267 Cafeteria】+ 01dp
- Codeforces Round #401 (Div. 2)Hanoi Factory CDQ分治
- opencv中关于Mat的智能指针的使用
- Lecture 3
- java服务端解决js跨域的问题 CORS(跨域资源共享) 的配置
- HSSF opi: excel中设置某列不可编辑
- 安卓开发中,release安装包安装后,打开app后再按home键,再次点击程序图标app再次重新启动的解决办法
- Spark集群,多个版本Python/Python Package管理
- Spring+SpringMVC+Mybatis 利用AOP自定义注解实现可配置日志快照记录
- C#异步的世界