BZOJ2276: [Poi2011]Temperature】的更多相关文章

2276: [Poi2011]Temperature Time Limit: 20 Sec  Memory Limit: 32 MBSubmit: 293  Solved: 117[Submit][Status] Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The measurement is done automatically, and its res…
题目链接 BZOJ2276 题解 一开始看错题,以为求的是可以不连续的,想出一个奇怪的线段树,发现空间根本开不下?? 题目要我们求连续的最长可能不下降区间 对于区间\([l,r]\)如果合法,当且仅当对于\(\forall i \in [l,r],\forall j < i\)满足\(l[j] <= r[i]\) 所以我们只需维护一个\(l[i]\)递减的单调队列即可 为什么是对的呢? 对于位置\(i\),显然至少取\(l[i]\),最多取\(r[i]\),如果存在\(l[j] > r[…
这题有两种写法,而且是完全(几乎?)不一样的写法...并不是换了个方法来维护而已 单调队列O(N):用一个队列维护a[]的单调递减,对于每个i满足a[队头]<=b[i],然后就可以算出以每一位为结尾的最大答案了 #include<stdio.h> #include<cstring> #include<iostream> #include<cstdlib> using namespace std; ,inf=1e9; int n,fir,ans; int…
浅谈队列:https://www.cnblogs.com/AKMer/p/10314965.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php?id=2276 假设一段区间满足不降的要求,那么充要条件是\(l_{max}<=r_{min}\) 所以我们用单调队列维护\(l\)的最大值然后更新答案即可. 时间复杂度:\(O(n)\) 时间复杂度:\(O(n)\) 代码如下: #include <cstdio> #include <…
题面 Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The measurement is done automatically, and its result immediately printed. Unfortunately, the ink in the printer has long dried out... The employees of BI…
Description The Byteotian Institute of Meteorology (BIM) measures the air temperature daily. The measurement is done automatically, and its result immediately printed. Unfortunately, the ink in the printer has long dried out... The employees of BIM h…
Code: #include<bits/stdc++.h> #define maxn 3000000 using namespace std; void setIO(string s) { string in=s+".in"; freopen(in.c_str(),"r",stdin); } deque<int>q; int l[maxn],r[maxn]; int main() { // setIO("input");…
Description 某国进行了连续n天的温度测量,测量存在误差,测量结果是第i天温度在[l_i,r_i]范围内. 求最长的连续的一段,满足该段内可能温度不降 第一行n 下面n行,每行l_i,r_i 1<=n<=1000000 一行,表示该段的长度 Sample Input 6 6 10 1 5 4 8 2 5 6 8 3 5 Sample Output 4 ———————————————————————————————————— 这道题其实就是维护一个连续的不下降序列 考虑维护一个队列 对…
POI2011题解 2214先咕一会... [BZOJ2212][POI2011]Tree Rotations 线段树合并模板题. #include<cstdio> #include<algorithm> using namespace std; int gi(){ int x=0,w=1;char ch=getchar(); while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar(); if (ch=='-') w=0…
正规.严谨.精妙. -POI BZOJ 1531 : [POI2005]Bank notes 裸的背包,可以二进制拆分一下.一个物品比如说有n个,可以拆成 1,2,4,8,16...个. OJ上没有样例,这里附上原题样例. In: 3 2 3 5 2 2 1 10 Out: 3 样例解释:略. BZOJ 2084 : [Poi2010]Antisymmetry 根据定义,回文串的长度必定是偶数,然后可以用回文串算法Manacher,因为是"反对称"只需把条件改成!=即可. BZOJ 2…