首页 > 其他分享 >Luogu P3488 [POI2009]LYZ-Ice Skates

Luogu P3488 [POI2009]LYZ-Ice Skates

时间:2022-10-25 14:01:14浏览次数:88  
标签:POI2009 lc Luogu ll tree Ice build rc include


题目链接:​​传送门​

号脚的人可以穿大小的鞋
号脚的人的数量
假设选择区间
就要满足
提出来

维护一个全局最大子段和就好了

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <algorithm>
#include <climits>
#include <queue>
#include <map>
#include <ctime>
#include <set>
#include <vector>
#include <iomanip>
#define
#define

using namespace std;
typedef long long ll;
struct node {
ll l, r, w, lc, rc, c;
}tree[A];
ll n, m, kk, d, a, b, c;
void up(ll k) {
tree[k].w = tree[k << 1].w + tree[k << 1 | 1].w;
tree[k].lc = max(tree[k << 1].lc, tree[k << 1].w + tree[k << 1 | 1].lc);
tree[k].rc = max(tree[k << 1 | 1].rc, tree[k << 1 | 1].w + tree[k << 1].rc);
tree[k].c = max(max(tree[k << 1].c, tree[k << 1 | 1].c), tree[k << 1].rc + tree[k << 1 | 1].lc);
}
void build(ll k, ll l, ll r) {
tree[k].l = l;
tree[k].r = r;
if (l == r) {
tree[k].w += -kk;
tree[k].lc = tree[k].rc = tree[k].c = tree[k].w;
return;
}
ll m = (l + r) >> 1;
build(k << 1, l, m);
build(k << 1 | 1, m + 1, r);
up(k);
}
void change(ll k) {
if (tree[k].l == tree[k].r) {
tree[k].w += c;
tree[k].lc = tree[k].rc = tree[k].c = tree[k].w;
return;
}
ll m = (tree[k].l + tree[k].r) >> 1;
if (a <= m) change(k << 1);
else change(k << 1 | 1);
up(k);
}

int main(int argc, char *argv[]) {
scanf("%lld%lld%lld%lld", &n, &m, &kk, &d);
build(1, 1, n);
while (m--) {
scanf("%lld%lld", &a, &c);
change(1);
if (tree[1].c <= d * kk) puts("TAK");
else puts("NIE");
}
}


标签:POI2009,lc,Luogu,ll,tree,Ice,build,rc,include
From: https://blog.51cto.com/lyle/5794678

相关文章

  • Luogu P4105 [HEOI2014]南园满地堆轻絮
    题目链接:​​传送门​​明显的二分简单的check我的没有longlong会炸掉50分#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>#include<comple......
  • Luogu P3313 [SDOI2014]旅行
    题目链接:​​传送门​​动态开点+树剖的模板吧。都很熟的话就挺好写的特别注意在dfs序上修改#include<iostream>#include<cstdio>#include<cstring>#include<cstdli......
  • Luogu P2412 查单词
    题目链接:​​传送门​​做完这个题感觉我是个沙雕在越做越麻烦的道路上一去不复返我真傻,真的(会有大量冗余变量)#include<iostream>#include<cstdio>#include<cstring>......
  • k8s之serviceAccount创建
    1、创建serviceAccountvim serviceAccount.yaml---apiVersion:v1kind:ServiceAccountmetadata:name:springcloud-kubernetesnamespace:dev---kind:Rol......
  • 1.1 WCF SOA架构和webservice
    1.什么是SOA?SOA全称:面向服务架构(serviceOrientedArchitecture),它是一种组件架构模式。一、定义1.WebService:严格来说是行业标准,不是技术,使用XML扩展标记语言来表示数据......
  • Solve CG FC200 E135 Device not activated
    SolveCGFC200E135Devicenotactivated   HowtoSolveCGFC200E135Devicenotactivated?HeresharesthesolutiontoresolveCGFC200Error‘E135:......
  • 六、Service
    6.1 Service的概念 KubernetesService定义了这样一种抽象:一个Pod的逻辑分组,一种可以访问它们的策略——通常称为微服务。这一组Pod能够被Service访......
  • 【luogu ARC106E】Medals(二分)(高维前缀和)
    Medals题目链接:luoguARC106E题目大意有n个第i个人的出现规律是对于所有2aik+1~2ai(k+1)的区间,2aik+1~2aik+ai会出现,另一部分则会不见。每个时间点你可以选择一......
  • Docker 使用GPU 错误之Error could not select device driver ““ with capabilities
    Docker使用GPU错误之Errorcouldnotselectdevicedriver““withcapabilities:[[gpu]]错误之Errorresponsefromdaemon:couldnotselectdevicedriver““......
  • 【Azure 云服务】Cloud Service Worker Role Workerrole突然停机,查看Events发现 Defra
    问题描述CloudServiceWorkerRoleWorkerrole突然停机,查看Events,发现是错误源为Defrag。错误消息:ThevolumeWindowswasnotoptimizedbecauseanerrorwasenco......