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 ...
随机推荐
- 类似nike+、香蕉打卡的转场动画效果-b
首先,支持并感谢@wazrx 的 http://www.jianshu.com/p/45434f73019e和@onevcat 的https://onevcat.com/2013/10/vc-tran ...
- 【弱省胡策】Round #5 Construct 解题报告
这个题是传说中的 Hack 狂魔 qmqmqm 出的构造题.当然要神. 这个题的本质实际上就是构造一个图,然后使得任意两点间都有长度为 $k$ 的路径相连,然后对于任意的 $i < k$,都存在 ...
- 用CImage类来显示PNG、JPG等图片
系统环境:Windows 7软件环境:Visual Studio 2008 SP1本次目的:实现VC单文档.对话框程序显示图片效果 CImage 是VC.NET中定义的一种MFC/ATL共享类,也是A ...
- 【leetcode】Word Break (middle)
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...
- ubuntu 和 win7 远程登陆 + vnc登陆
ubuntu 和 win7 远程登陆: 第一种(通过win7自带的远程桌面来连接ubuntu) 1. windows7配置 我的电脑->属性->远程设置.-----允许远程连接 2. ub ...
- HDU2697+DP
dp[i][j]:从前i个中挑出某些且cost不超过j的最大val. dp[i][j]:应该有1到i-1的dp[k][j-?]来更新!! /* DP dp[i][j]:从前i个中挑出某些且cost不超 ...
- JS 封装类
function HighchartsObj(id, type) { var that = this; this.options = { chart : { renderTo : id, type : ...
- MVC @Html.DropDownListFor 默认值
今天在做MVC 的 @Html.DropDownListFor 的时候,本来数据库中读取到的值是HK,但是 @Html.DropDownListFor的起始默认值始终是“请选择国家”,搞了一个下午, ...
- Qt4.6.2已编译二进制版本在VS2005中的问题
结论1:如果你想把Qt4.6.2安装在VS2005中,又不想花时间编译,请下载和安装qt-win-opensource-4.6.2-vs2008,并单独编译“QT安装路径/src/winmain/” ...
- Android 去除EditText边框,添加下划线,
首先:重写EditText //请在这里添加您的包名 import android.content.Context; import android.graphics.Canvas; import an ...