FOJ 1608 Huge Mission 线段树
每个节点维护一个最小值,更新发现如果大于最小值,直接向下更新。速度还可以。。
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
const int maxn=;
int sum[maxn<<],b[maxn<<];
void pushup(int rt)
{
sum[rt]=sum[rt*]+sum[rt*+];
b[rt]=min(b[rt*],b[rt*+]);
}
void change(int rt,int l,int r,int x,int y,int c)
{
int m=(l+r)>>;
if(l==r)
{
sum[rt]=b[rt]=c;
return;
}
if(x<=m&&b[rt*]<c)change(rt*,l,m,x,y,c);
if(y>m&&b[rt*+]<c)change(rt*+,m+,r,x,y,c);
pushup(rt);
}
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m))
{
int x,y,z;
memset(sum,,sizeof(sum));
memset(b,,sizeof(b));
for(int i=; i<m; i++)
{
scanf("%d%d%d",&x,&y,&z);
change(,,n,x+,y,z);
}
printf("%d\n",sum[]);
}
return ;
}
FOJ 1608 Huge Mission 线段树的更多相关文章
- FZU 1608 Huge Mission(线段树)
Problem 1608 Huge Mission Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Oaiei ...
- FZU-1608 Huge Mission 线段树(更新懒惰标记)
题目链接: https://cn.vjudge.net/problem/FZU-1608 题目大意: 长度n,m次操作:每次操作都有三个数:a,b,c:意味着(a,b]区间单位长度的价值为c,若某段长 ...
- FZU 1608 Huge Mission
Huge Mission Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original I ...
- FZU_1608 Huge Mission 【线段树区间更新】
一.题目 Huge Mission 二.分析 区间更新,用线段树的懒标记即可.需要注意的时,由于是在最后才查询的,没有必要每次更新都对$sum$进行求和.还有一点就是初始化的问题,一定记得线段树上每个 ...
- FZU1608(线段树)
传送门:Huge Mission 题意:给定区间范围[0,N] (2 <= N <= 50000)和M个区间 (1 <= M <= 500000)和这些区间上的权值,求最终并区 ...
- UVALive 7141 BombX(离散化+线段树)(2014 Asia Shanghai Regional Contest)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=6 ...
- hdu 1754:I Hate It(线段树,入门题,RMQ问题)
I Hate It Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- I Hate It(hdu1754)(线段树区间最大值)
I Hate It hdu1754 Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
- Stars(树状数组或线段树)
Stars Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37323 Accepted: 16278 Description A ...
随机推荐
- IOS9中出现的错误
1,Bitcode 错误提示: ld: '/Applications/Cocos/frameworks/cocos2d-x-3.8.1/prebuilt/ios/libcocos2d iOS.a(CC ...
- sql之独立子查询和相关子查询总结
1.独立子查询:顾名思义:就是子查询和外层查询不存在任何联系,是独立于外层查询的: 下面就看一个例子: 有一张订单表 Sales.Order 和一张 客户表 Sales.Customer 下面的sql ...
- C#学习笔记---基础入门(一)
C#中的变量: 一个变量就是存储区(内存)中的一个存储单元. 变量声明赋值:int money =1000;/int money;money=1000; 输出:console.writeLine(mo ...
- linux内核分析之内存管理
1.struct page /* Each physical page in the system has a struct page associated with * it to keep tra ...
- having——至少被订购过两回的订单
此篇介绍having的用法 一.表:订单表,产品表 说明:订单表order ,包含prodectid 二.查询至少被订购过两回的订单 800x600 Normal 0 7.8 磅 0 2 false ...
- 【技术贴】webservice cxf2 客户端动态调用报错No operation was found with the name
No operation was found with the name xxx 出错原因是因为发布服务的接口所在包路径和此接口实现类包路径不一致,比如你的服务接口可能放在了包com.x.interF ...
- Eclipse console文本换行
Eclipse换行主要有3个方面 格式化时编辑器文本换行 源代码注释文本换行 Eclipse控制台console显示文本换行 1和2参考 http://hi.baidu.com/ae6623/item ...
- PHP htmlspecialchars() 函数
定义和用法 htmlspecialchars() 函数把一些预定义的字符转换为 HTML 实体. 预定义的字符是: & (和号) 成为 & " (双引号) 成为 " ...
- iOS设计模式——委托(delegate)
委托(delegate)也叫代理是iOS开发中常用的设计模式.我们借助于protocol(参考博文:objective-c协议(protocol))可以很方便的实现这种设计模式. 什么是代理? 苹果的 ...
- JAVA面试题:69道Spring面试题和答案
目录 Spring 概述 依赖注入 Spring beans Spring注解 Spring数据访问 Spring面向切面编程(AOP) Spring MVC Spring 概述 1. 什么是spri ...