Codeforces Round #433(Div. 1,based on Olympiad of Metropolises)A Planning B Jury Meeting C Boredom

C. Boredom (简单的一维DP) C. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bore 阅读详情

人生的第一次div.1 掉分 QAQ

A - Planning

http://codeforces.com/contest/853/problem/A

贪心,排个序,优先安排花费大的,用模拟链表实现的

#include<bits/stdc++.h>
#define eps 1e-9
#define PI 3.141592653589793
#define bs 1000000007
#define bsize 256
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
using namespace std;
struct node
{
	int t,index;
}a[1000005];
int cmp(node u,node v)
{
	return u.t>v.t;
}
int pre[1000005],ne[1000005];
int ans[1000000];
int book[1000000];
int main()
{
	int n,k,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i].t);
		a[i].index=i;
	}
	for(i=0;i<=1000000;i++)
	{
		if(i!=0)
		pre[i]=i-1;
		ne[i]=i+1;
	}
	sort(a+1,a+1+n,cmp);
	long long sum=0;
	int now=k+1;
	for(i=1;i<=n;i++)
	{
		if(a[i].index<=now)
		{
			sum+=1ll*(now-a[i].index)*a[i].t;
			ans[a[i].index]=now;
			ne[pre[now]]=ne[now];
			pre[ne[now]]=pre[now];
			now=ne[now];	
		}
		else
		{
			ans[a[i].index]=a[i].index;
			ne[pre[a[i].index]]=ne[a[i].index];
			pre[ne[a[i].index]]=pre[a[i].index];	
		}
	}
	cout<<sum<<endl;
	for(i=1;i<=n;i++)
	printf("%d ",ans[i]);
	cout<<endl;
 }


B - Jury Meeting

http://codeforces.com/contest/853/problem/B

题意看了半天,看懂题意,其实就很水了。。

也是排个序,记录一下前缀最小花费,后缀最小花费,最后扫一遍就可以了

#include<bits/stdc++.h>
#define eps 1e-9
#define PI 3.141592653589793
#define bs 1000000007
#define bsize 256
#define MEM(a) memset(a,0,sizeof(a))
typedef long long ll;
using namespace std;
int n,m,k;
long long dp[2][1000005];
long long need[2][1000005];
struct node
{
	int d,f,t,c;
}a[100005];
int cmp(node u,node v)
{
	return u.d<v.d;
}
const ll inf=0x3f3f3f3f3f3f3f3f;
int main()
{
	int i;
	cin>>n>>m>>k;
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d %d",&a[i].d,&a[i].f,&a[i].t,&a[i].c);	
	}
	sort(a,a+m,cmp);
	memset(need,-1,sizeof(need));
	memset(dp,inf,sizeof(dp));
	ll sum=0,now=0;
	for(i=0;i<m;i++)
	{
		if(a[i].f)
		{
			if(need[0][a[i].f]==-1)
			{
				now++;
				sum+=a[i].c;
				need[0][a[i].f]=a[i].c;
			}
			else if(a[i].c<need[0][a[i].f])
			{
				sum+=a[i].c-need[0][a[i].f];
				need[0][a[i].f]=a[i].c;
			}
			if(now==n)
			{
				dp[0][a[i].d]=min(dp[0][a[i].d],sum);
			}
		}
	}
	now=0,sum=0;
	for(i=m-1;i>=0;i--)
	{
		if(a[i].t)
		{
			if(need[1][a[i].t]==-1)
			{
				now++;
				sum+=a[i].c;
				need[1][a[i].t]=a[i].c;
			}
			else if(a[i].c<need[1][a[i].t])
			{
				sum+=a[i].c-need[1][a[i].t];
				need[1][a[i].t]=a[i].c;
			}
			if(now==n)
			{
				dp[1][a[i].d]=min(dp[1][a[i].d],sum);
			}
		}
	}
	for(i=1;i<=1000000;i++)
	{
		dp[0][i]=min(dp[0][i],dp[0][i-1]);
	}
	for(i=1000000;i>=0;i--)
	{
		dp[1][i]=min(dp[1][i],dp[1][i+1]);
	}
	long long ans=inf;
	for(i=0;i+k<=1000000;i++)
	{
		ans=min(ans,dp[0][i]+dp[1][i+k+1]);
	}
	if(ans==inf)
	cout<<-1<<endl;
	else
	cout<<ans<<endl;
	return 0;
 }
C - Boredom
http://codeforces.com/contest/853/problem/C

主席树,主席树主要是用来快速统计某个子矩阵里标记点的个数,因为每列只被标记一个,所以主席树可以搞,但当时思路并不是很清晰,手速也太慢,后来想通了其实也还好

这样就可以快速的查询某个子矩阵里标记点的个数,对于每个查询的矩阵,我们只需要求不在这个矩阵里的所有 beautiful rectangles个数即可,也就是两个被标记的点都在查询矩阵的上方,下方,左方,右方,最后在去一下重。


#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int l[30*maxn],r[30*maxn],sz[30*maxn];
int tot=0,t[maxn],p[maxn];
int build(int le,int ri)
{
    int root=tot++;
    sz[root]=0;
    int m=(le+ri)>>1;
    if(le!=ri)
    {
        l[root]=build(le,m);
        r[root]-build(m+1,ri);
    }
    return root;
}
int update(int root,int le,int ri,int x,int k)
{
    int now=tot++;
    sz[now]=sz[root]+k;
    if(le==ri)
        return now;
    int m=(le+ri)>>1;
    if(x<=m)
    {
        l[now]=update(l[root],le,m,x,k);
        r[now]=r[root];
    }
    else
    {
        r[now]=update(r[root],m+1,ri,x,k);
        l[now]=l[root];
    }
    return now;
}
int query(int root,int le,int ri,int L,int R)
{
    if(L>R)
        return 0;
    if(L<=le&&R>=ri)
    {
        return sz[root];
    }
    if(le==ri)
    {
        return sz[root];
    }
    int sum=0;
    int m=(le+ri)>>1;
    if(m>=L)
    {
        sum+=query(l[root],le,m,L,R);
    }
    if(m<R)
    {
        sum+=query(r[root],m+1,ri,L,R);
    }
    return sum;
}
inline long long f(int x)
{
    return 1ll*x*(x-1)/2;
}
int main()
{
	int i,n,q,l,r,u,d;
	cin>>n>>q;

	t[0]=build(1,n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		t[i]=update(t[i-1],1,n,p[i],1);
	}
	long long ans=0;
//	cout<<query(t[0],1,n,1,n)<<endl;
	while(q--)
	{
	    ans=f(n);
		scanf("%d %d %d %d",&l,&d,&r,&u);
		int temp1=query(t[n],1,n,1,n)-query(t[r],1,n,1,n);
		int temp2=query(t[n],1,n,u+1,n);
		int temp3=temp2-query(t[r],1,n,u+1,n);
		int temp4=query(t[l-1],1,n,1,n);
		int temp5=query(t[n],1,n,1,d-1);
		int temp6=temp5-query(t[r],1,n,1,d-1);
		int temp7=temp4-query(t[l-1],1,n,1,u);
		int temp8=query(t[l-1],1,n,1,d-1);
	//	cout<<temp1<<" "<<temp2<<" "<<temp3<<" "<<temp4<<" "<<temp5<<" "<<temp6<<" "<<temp7<<" "<<temp8<<endl;
		ans-=f(temp1)+f(temp2)+f(temp4)+f(temp5)-f(temp3)-f(temp7)-f(temp8)-f(temp6);
		printf("%lld\n",ans);
	}
	return 0;
 }




WOFOST模型参数调优实战:从‘跑不通’到‘预测准’的避坑指南 本文详细介绍了WOFOST模型参数调优的实战技巧,帮助用户从模型报错诊断到参数敏感性分析,再到土壤-作物参数联调策略,逐步解决‘跑不通’到‘预测准’的问题。通过Python和PCSE工具,提供参数扰动测试模板和关键参数优先级矩阵,助力作物模型的高效校准与预测。 阅读详情

相关推荐

运动目标成像必学:5分钟搞懂keystone变换原理与避坑指南

本文深入浅出地解析了雷达信号处理中的Keystone变换原理,它是解决运动目标距离徙动问题的关键技术。文章通过直观比喻和简化公式,阐述了该变换如何通过变量代换实现距离与慢时间的解耦合,将倾斜轨迹“掰直”,从而提升成像与检测性能。同时,文中重点指出了实际应用中关于大速度场景、插值误差、多目标处理及高阶运动补偿等关键避坑点,为工程实践提供了宝贵指南。

ios99的博客 411

CF #576 Div.1 E. Rectangle Painting 2 //最大流(最小点覆盖)

题意: 思路: 离散化,将所有边都延长割成网状,割成一个个小矩形,左闭右开统计大矩阵由小矩阵组成。 最小点覆盖→\rightarrow→二分图最大匹配→\rightarrow→最大流 建图:边权为对应的花费,长→\rightarrow→宽 的边权为 infinfinf. 源点→\rightarrow→矩阵的长→\rightarrow→矩阵的宽→\rightarrow→汇点 跑最大流 不愧*25...

Rshs 341

YOLOv11+SAHI实战:5步搞定无人机航拍小目标检测(附VisDrone数据集调参技巧)

本文详细介绍了如何结合YOLOv11目标检测框架与SAHI切片推理技术,高效解决无人机航拍图像中的小目标检测难题。通过VisDrone数据集调参技巧和5步实战指南,帮助开发者快速构建高性能检测系统,显著提升小目标检测的准确率和效率。

rum55的博客 194

Codeforces Round #433 C - Boredom

贪心。#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<ctime> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<queue> #include<utility> #inclu

now_ing的博客 358

ERA5数据批量下载

ERA5再分析数据的IDM接管下载

qq_38734327的博客 3045

自动驾驶仿真 (四)—— 基于PreScan与Simulink的AEB系统多场景验证

本文详细介绍了基于PreScan与Simulink的AEB系统多场景验证方法,涵盖标准场景搭建、复杂工况扩展及控制策略优化。通过仿真技术,显著降低测试成本并提升场景覆盖率,有效解决实车测试中的痛点问题。特别适用于自动驾驶领域的AEB系统开发与验证。

weixin_28273593的博客 252

【Author : DS】CF #140 非常好的一套CF题目,DIV1 的E题实在没辙

DIV 2 A 给三个点,为从A - B - C的过程中,是要向左转还是右转还是直行。 方法很简单,叉积嘛。 #define typec long long struct Point2D{ typec x,y; Point2D(){} Point2D(typec _x,typec _y):x(_x),y(_y){}; void input(){

向往纳木错的程序猿生活 1639

llama2-7b下载并转llama-2-7b-hf

④输入https://github.com/huggingface/transformers/blob/main/src/transformers/models/llama/convert_llama_weights_to_hf.py会下载 convert_llama_weights_to_hf.py 文件,我们需要用到这个文件将llama2-7b转成llama-2-7b-hf。③下载完之后是这四个文件,这里我是在windows操作系统中安装的WSL,没有linux操作系统,没办法。

wenling54321的博客 1036

A. Boredom

解题说明:此题是一道动态规划题,做法是先存下每个数的个数放在c中,消除一个数i,会获得c[i]*i的值(因为可以消除c[i]次),如果从0的位置开始向右消去,那么,消除数i时,i-1可能选择了消除,也可能没有, 如果消除了i-1,那么i值就已经不存在,dp[i] = dp[i-1],如果没有被消除,那么dp[i] = dp[i-2]+ c[i]*i。 在上面两者中取最大值即可。

无知的我 1864

5分钟快速上手:用AI生成3D虚拟场景的保姆级教程

你是否想过:不用学复杂的3D建模软件,不用懂“多边形”“UV贴图”这些专业术语,也能快速生成一个梦幻的森林、未来感的城市,甚至外太空基地?本文的目的就是教完全没接触过3D技术的新手,用AI工具5分钟生成3D虚拟场景。我们会覆盖主流AI工具的选择、提示词编写技巧、生成后的简单调整,以及常见问题解决。本文会像“游戏任务指南”一样,从“认识工具”→“写提示词”→“生成场景”→“调整优化”逐步讲解,最后还会教你把生成的3D场景用起来!提示词:你给AI的“订单备注”,越详细效果越好。扩散模型。

AI 原生应用开发的博客 1994

小工匠聊架构-分布式场景下的并发幂等性常见的解决方案

Pre 我们来回顾下单体时代 单体时代,应用部署在一台主机上,可以使用JVM级别的锁来控制并发请求 。 随着应用规模的不断扩大,集群化或者微服务化的分布式部署越来越普及,每个应用都是一个单独的JVM应用,所以单体时代的这种处理方式已经无法满足当前架构下的业务需求了。 JVM级别的锁已经无法满足跨进程之间访问控制了,进而演化出来了分布式锁。 分布式锁 能否解决幂等性问题? 分布式锁解决什么问题? 简言之: 解决跨进程间无法共享本地资源的问题 ,解决的是分布式场景下并发访问的问题。 为什么需要确保并发.

小工匠 2万+

CodeForces 456C - Boredom(DP)

C. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alex doesn't like boredom. That's why whenever he gets bore

Waves___的博客 954

手把手教你ensp仿真搭建校园网(含防火墙及无线网络)系列(三)校园无线网络AC+AP配置

本系列博客将带你从零开始,使用 华为 eNSP(Enterprise Network Simulation Platform) 仿真搭建一个完整的校园网络,涵盖 核心层、汇聚层、接入层、防火墙安全策略、无线AC+AP组网 等实战场景。无论你是网络初学者还是希望深化实战经验的工程师,都能通过本教程掌握企业级网络的规划、配置与排错技巧。

echo的博客 1381

Codeforces Round #433 (Div. 1, based on Olympiad of Metropolises) C. Boredom(主席树)

题目链接:http://codeforces.com/contest/853/problem/C 查二维平面里有多少点,按行维护主席树,然后每次查一个区间,做差就可以求出二维平面里的点了,然后剩下的容斥一哈就行了,具体是把周围一圈剪掉,然后把四个角加上就好了,比较简单 代码: #include using namespace std; typedef long long ll

bibibibi的博客 448

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

Codeforces Round #433 (Div. 1) B Jury Meeting(思维)

感觉cf的题目很难分类,但是总能给个思维.. 这题卡了很久啊,一开始没看清题目,老觉得有很多很多城市,里面选出个别来参加会议,后来发现是所有城市都要来..T^T 扫一遍,然后更新一个数组,l[i],意为在i天及i天之前所有人都要抵达需要的最少钱,r[i]同理了. 然后枚举l~l+k就可以了 还是那句话,d题从题目信息,思路,代码难度,代码细节都完爆了c题 我好菜啊好菜啊T^T/* xzp

blog 272

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

Codeforces Contest 853 C. Boredom —— 主席树求相交矩形数

This way 题意: 有一个n*n的矩形,每一列上都会有一个被标记的方块,所有被标记的方块的行数都不相同。一个矩形被称为美丽矩形当且仅当它的四个角正好有两个方块被标记。有q个询问,每次给你一个矩形,问你有多少被标记的矩形与这个矩形相交。 题解: 一个美丽矩形与这个矩形不相交当且仅当这两个被标记的方块在所选矩形的外侧同一侧,我们用主席数来维护,按x轴建树,存每一列被标记格子的行数。接下来只需要用...

天翼之城的博客 311

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Codeforces Round #382 (Div. 2)A到D题 A. Ostap and //B. Urbanization//C. Tennis Championship//D. Taxes

A. Ostap and Grasshopper time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output On the way to Rio de Janeiro Ostap

jerans的博客 1289

Gym - 101128C Canvas Painting 逆向思维

https://odzkskevi.qnssl.com/3699857ff0a17d77d1099699cdf4da13?v=1490503337 刚开始读错题意,以为是不变序列,就想着区间dp但数据量肯定会t,,,没想到什么优化方法就放下了,后来队员发现序列是可变的。。。。任意的。。。。。 想着先排序在布拉布拉布拉,一直都没有逆向思维想到哈夫曼。只怪数据结构没认真听啊。。。。 想到哈夫

jerans的博客 947

CodeForces - 361D Levko and Array二分加dp

D. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of inte

jerans的博客 840

Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) C Fountains 乱搞

C. Fountains time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Arkady plays Gardenscapes a lot. Arkady wants

jerans的博客 811

codeforces 8VC Venture Cup 2017 - Elimination Round D PolandBall and Polygon

D. PolandBall and Polygon time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output PolandBall has such a convex poly

jerans的博客 726

B. The Meeting Place Cannot Be Changed

B. The Meeting Place Cannot Be Changed time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output The main road in Byt

jerans的博客 697

Codeforces Round #380 (Div. 2,Based on Technocup 2017 - Elimination Round 2)C - Road to Cine//

C. Road to Cinema time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya is currently at a car rental service

jerans的博客 684

Beautiful numbers CodeForces - 55D 数位dp

D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is

jerans的博客 677

Codeforces Round #423 (Div. 2) C. String Reconstruction思维 D. High Load 构造

C:http://codeforces.com/contest/828/problem/C 题意:有一个字符串,你知道他的一些子串所在的位置,求符合条件的字典序最小的原串 因为已知的数据较大,还存在较多重复的部分,直接暴力不可行 可以记录原串每个位置的下一个没确定出来的字符的位置(记住next【i】),优化后可以过,时间较长 #include #define eps 1e-9 #defin

jerans的博客 672

Codeforces Round #410 (Div. 2) C. Mike and gcd problem 贪心

C. Mike and gcd problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a sequence A = [a1, a2, ..

jerans的博客 664
上一篇: Codeforces Round #432 (Div. 2) D. Arpa and a list of numbers E. Arpa and a game with Mojtaba
下一篇: hdu 5900 区间dp
jerans
博客等级 码龄10年 54粉丝 255原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值