POJ 2970 The lazy programmer(优先队列+贪心)

利用NLP技术分析爬取的文本数据:Python爬虫与自然语言处理实战 网页爬虫(Web Crawler)是一种自动化脚本,通过模拟人类浏览网页的方式,定期抓取网页内容并进行分析和存储。对于大规模的数据抓取任务,爬虫技术提供了极大的便利。常见的Python爬虫库有requestsSelenium等。在本篇博客中,我们从爬取网页文本数据开始,通过清洗和预处理,最终利用自然语言处理技术(包括情感分析、文本分类等)对数据进行了深度分析。通过该过程,我们展示了如何使用Python爬虫抓取文本数据,并利用NLP技术进行分析和建模。 阅读详情



Language:
The lazy programmer
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 1566 Accepted: 386

Description

A new web-design studio, called SMART (Simply Masters of ART), employs two people. The first one is a web-designer and an executive director at the same time. The second one is a programmer. The director is so a nimble guy that the studio has already got N contracts for web site development. Each contract has a deadline di.

It is known that the programmer is lazy. Usually he does not work as fast as he could. Therefore, under normal conditions the programmer needs bi of time to perform the contract number i. Fortunately, the guy is very greedy for money. If the director pays him xi dollars extra, he needs only (bi − ai xi) of time to do his job. But this extra payment does not influent other contract. It means that each contract should be paid separately to be done faster. The programmer is so greedy that he can do his job almost instantly if the extra payment is (bi ⁄ ai) dollars for the contract number i.

The director has a difficult problem to solve. He needs to organize programmer’s job and, may be, assign extra payments for some of the contracts so that all contracts are performed in time. Obviously he wishes to minimize the sum of extra payments. Help the director!

Input

The first line of the input contains the number of contracts N (1 ≤ N ≤ 100 000, integer). Each of the next N lines describes one contract and contains integer numbers ai, bi, di (1 ≤ ai, bi ≤ 10 000; 1 ≤ di ≤ 1 000 000 000) separated by spaces.

Output

The output needs to contain a single real number S in the only line of file. S is the minimum sum of money which the director needs to pay extra so that the programmer could perform all contracts in time. The number must have two digits after the decimal point.

Sample Input

2
20 50 100
10 100 50

Sample Output

5.00

Source

Northeastern Europe 2004, Western Subregion



/*

题意:有n个任务要完成,每个任务有属性 a,b,d
	 分别代表  额外工资,完成时间,结束时间。
	 如果不给钱,那么完成时间为b,给x的额外工资,那么完成时间b变成 b-a*x

  求在所有任务在各自最后期限前完成所需要给的最少的钱

思路:先把任务按照结束之间排序,然后依次完成每个任务,如果这个任务无法完成
      那么在前面(包括这个)任务中找到a属性最大的任务(可以再给他钱的前提),
      给钱这个腾出时间来完成当前这个任务,而这个可以用优先队列维护


*/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>


#define L(x) (x<<1)
#define R(x) (x<<1|1)
#define MID(x,y) ((x+y)>>1)

#define eps 1e-8
typedef __int64 ll;

#define fre(i,a,b)  for(i = a; i <b; i++)
#define free(i,b,a) for(i = b; i >= a;i--)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define ssf(n)      scanf("%s", n)
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pf          printf
#define bug         pf("Hi\n")

using namespace std;

#define INF 0x3f3f3f3f
#define N 100005

struct stud{
  int a,b,d;
  double money;
  bool operator<(const stud b) const
  {
  	return a<b.a;
  }

}f[N];

int cmp(stud x,stud y)
{
	return x.d<y.d;
}

priority_queue<stud>q;

int n;

int main()
{
	int i,j;
	while(~scanf("%d",&n))
	{
		for(i=0;i<n;i++)
			{
				scanf("%d%d%d",&f[i].a,&f[i].b,&f[i].d);
			    f[i].money=0;   //已经给这个任务的钱
			}
	    sort(f,f+n,cmp);

	    while(!q.empty()) q.pop();
	    double ans,day;
	    ans=day=0;
	    stud cur;
	    for(i=0;i<n;i++)
		{
			q.push(f[i]);
			day+=f[i].b;
			while(day>f[i].d)
			{
				cur=q.top();
				q.pop();
				double temp=(double)(day-f[i].d)/cur.a; //完成这个任务需要给cur任务的钱
				if(temp+cur.money<(double)cur.b/cur.a)   //如果这个钱加上已经给的钱小于可以给他的钱
				{
					day-=temp*cur.a;
					cur.money+=temp;
					ans+=temp;
					q.push(cur);
					break;
				}
				else
				{
					temp=((double)cur.b/cur.a-cur.money);
					day-=temp*cur.a;
					ans+=temp;
				}
			}
		}

		printf("%.2f\n",ans);
	}
  return 0;
}










Language:
The lazy programmer
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 1566 Accepted: 386

Description

A new web-design studio, called SMART (Simply Masters of ART), employs two people. The first one is a web-designer and an executive director at the same time. The second one is a programmer. The director is so a nimble guy that the studio has already got N contracts for web site development. Each contract has a deadline di.

It is known that the programmer is lazy. Usually he does not work as fast as he could. Therefore, under normal conditions the programmer needs bi of time to perform the contract number i. Fortunately, the guy is very greedy for money. If the director pays him xi dollars extra, he needs only (bi − ai xi) of time to do his job. But this extra payment does not influent other contract. It means that each contract should be paid separately to be done faster. The programmer is so greedy that he can do his job almost instantly if the extra payment is (bi ⁄ ai) dollars for the contract number i.

The director has a difficult problem to solve. He needs to organize programmer’s job and, may be, assign extra payments for some of the contracts so that all contracts are performed in time. Obviously he wishes to minimize the sum of extra payments. Help the director!

Input

The first line of the input contains the number of contracts N (1 ≤ N ≤ 100 000, integer). Each of the next N lines describes one contract and contains integer numbers ai, bi, di (1 ≤ ai, bi ≤ 10 000; 1 ≤ di ≤ 1 000 000 000) separated by spaces.

Output

The output needs to contain a single real number S in the only line of file. S is the minimum sum of money which the director needs to pay extra so that the programmer could perform all contracts in time. The number must have two digits after the decimal point.

Sample Input

2
20 50 100
10 100 50

Sample Output

5.00

Source

Northeastern Europe 2004, Western Subregion

Arcgis模型构建器01——写一个简单的模型 在使用模型构建器解决这个需求之前,我们要想清楚如果我们手动解决的话,应该如何去处理,因为构建模型的过程正是基于我们手动处理的过程来构建的。我有一个全国的dem影像数据和一个陕西省边界范围矢量,现在我想获取陕西省的dem影像的坡度数据。填写完之后点击确定,我们发现,两个输入数据和工具连接起来了,并且通过裁剪工具得到一个中间结果,即。我们发现工具框和中间数据框都存在阴影,说明已经运行过了这个模型,不报错就说明模型运行成功!现在我们就把数据和工具都串联起来了,成功构建好了模型。 阅读详情

相关推荐

COMSOL实现裂缝性储层油水两相流模拟的关键技术

多孔介质中的流体流动模拟是油气藏开发的核心技术,其基本原理基于达西定律和质量守恒方程。在裂缝性储层中,离散裂缝网络与基质系统的耦合流动带来了特殊的数值挑战。通过COMSOL Multiphysics平台实现的多物理场耦合技术,可以精确模拟油水两相在复杂裂缝系统中的渗流行为。该技术采用Level Set方法表征裂缝几何形态,结合自适应网格生成技术解决狭窄裂缝的网格剖分难题,并创新性地引入Bang-Larsen毛管压力滞后模型,显著提高了采收率预测精度。这些方法在致密油藏开发、水驱优化等工程实践中具有重要应用价

weixin_34005090的博客 229

【POJ 2970】The lazy programmer(优先队列+贪心)

这题范围不会超long long全用int存就行了 贪心的话,每次把一个任务加入到队列,如果不能在指定时间完成就到前面找a最小的一个任务补偿时间,当一个任务完成时间等于0的时候这个任务就不再放回队列 #include #include #include #include using namespace std; //typedef long long LL; const int maxn =

花月阁 1139

【AI气象6】Skilful nowcasting of extreme precipitation with NowcastNet

极端降水是气象灾害的重要因素,因此迫切需要通过高分辨率、长时间预报和局部细节的精准短期预报来减轻其社会经济影响。当前的方法存在模糊、衰减、强度或位置误差,基于物理的数值方法在捕捉关键的混沌动态(如对流起始)时面临挑战,而数据驱动的学习方法则未能遵循内在的物理法则(如平流守恒)。我们提出了 NowcastNet,这是一种针对极端降水的非线性短期预报模型,将物理演变方案与条件学习方法统一到一个端到端的神经网络框架中,通过优化预测误差进行训练。基于来自美国和中国的雷达观测数据,我们的模型能够生成物理上合理的降水短

weixin_51473374的博客 2322

poj2970The lazy programmer 优先队列+贪心

The lazy programmer Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 2421   Accepted: 605 Description A new web-design studio, called SMART (Simply Masters

天行健,君子以自强不息 539

保姆级教程:用微信小程序+OneNet MQTT API,5分钟搞定温湿度数据实时展示

本文提供了一份详细的教程,教你如何利用微信小程序和OneNet MQTT API在5分钟内实现温湿度数据的实时展示。从OneNet平台配置到小程序数据绑定,手把手指导零基础开发者快速搭建监控系统,涵盖API调用、数据解析和界面设计等关键步骤。

weixin_30298497的博客 368

【干货】SAP物料分类账的简单理解

一、SAP物料分类账理解 物料分类账,简称ML(material ledger),其基本用途是可以用八个字概括“还原成本”、“还原库存”。即通过月底运行物料分类账,将库存差异(原材料-材料成本差异、库存商品-自制半成本差异、库存商品-自制产成品差异)自动按当期库存出库数和库存结存数的比例分摊至成本和库存中。为了理解其概念,可以简单举一个例子: 开一工单,生产A产品,数量为3个,当月全部生产完工

ERP运维咨询(目标和成功) 1万+

POJ 2970 The lazy programmer

1、本题用贪心法以及优先队列,首先按照截止日期排序,然后用一个变量T记录时间,若T大于截止日期,则利用优先队列,选择当前最大的a值来将T减小。如果将b用完了,则将这个a出队。这样一直减,直到T等于截止日期。 2、要注意的是每次队列都要清空。 3、比较坑爹的是输出的时候用%lf是错的,改成%f就对了。。。原因似乎是历史遗留问题,当且仅当在POJ且用g++时,会出错,用c++是不会出错的。所以以后

427

【项目实战】AES实施应符合NIST密码算法验证程序

AES由美国国家标准与技术研究院(NIST)制定。NIST是负责开发和维护美国政府使用的技术标准的机构,包括加密标准。

奶爸的编程之路,也就一周冷个三天 765

Poj 2970 The lazy programmer(贪心)

题目地址:http://poj.org/problem?id=2970 思路: 1.按照d值从小到大排序,依次完成任务。 2.将所有已完成任务加入优先队列(a值越大越优先),若当前任务无法完成,则从队列中不断找到a值最大的任务,花费一定钱数减少完成时间,直到当前时间等于d。 3.若某任务花费值为b/a,则以后花费钱任务时间也不会减少,从队列中删除。 #include #include #

哆啦AC梦的博客 724

C语言试题四之计算并输出3到n之间所有素数的平方根之和

1、题目 请编写函数function,它的功能是:计算并输出3到n之间所有素数的平方根之和 例子:若我们main函数从键盘给n输入5之后,我们需要输出结果为3.968119 输入值n的要求:正整数n, 要求小于100。 2、部分函数说明 C 库函数 double sqrt(double x) 返回 x 的平方根 3、源代码实现 #include <stdio.h> #...

码莎拉蒂 7232

3、深入了解响应式扩展(Reactive Extensions)

本文深入探讨了响应式扩展(Reactive Extensions,Rx)的起源、核心概念及其在客户端和服务器端的应用。从Volta项目谈起,解析了Rx如何解决事件传输问题,并介绍了可观察对象(IObservable)和观察者(IObserver)的设计与实现机制。文章还详细讲解了Rx操作符、弹珠图的使用、拉模型与推模型的对偶性原理,并通过代码示例展示了如何将枚举转换为可观察对象。最后总结了Rx的优势,并展望其在未来软件开发中的广泛应用前景。

m2n3b4v5c6的博客 112

POJ 2970 The lazy programmer 优先队列

Description A new web-design studio, called SMART (Simply Masters of ART), employs two people. The first one is a web-designer and an executive director at the same time. The second one is a programm...

以梦为马,诗酒趁年华的博客 445

嵌入式视频应用开发者必读:嵌入式Linux+FFmpeg硬件编解码实战指南

在嵌入式Linux上,FFmpeg支持多种硬件加速API,比如VAAPI、VDPAU、CUDA,以及针对特定平台的专用接口(如NVIDIA的NVENC、Intel的QSV、ARM的Mali)。FFmpeg的硬件解码通过-hwaccel参数启用,咱们以常见的H.264和HEVC(H.265)格式为例,展示如何用VAAPI和V4L2实现高效解码。: FFmpeg硬件加速需要额外的库,比如libva(VAAPI)、libv4l2(V4L2)或libnvcodec(CUDA)。

大模型大数据攻城狮的专栏 2202

I - The lazy programmer 贪心+优先队列

来源poj2970 A new web-design studio, called SMART (Simply Masters of ART), employs two people. The first one is a web-designer and an executive director at the same time. The second one is a progra...

weixin_30338497的博客 199

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

优先队列专题

都是在书上找的。。 POJ 2051      Agri-Net     POJ 2431      Expedition POJ 3253      Fence Repair POJ 2970     The lazy programmer UVA 11997    K Smallest Sums   POJ2970    一直WA。。拿标程对拍了几个小时都没出来,想哭了。

天亮说晚安 1788

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

CF 332 C 贪心

CF 332 C 贪心

左眼皮跳跳 2292

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

HDU 1338 Game Prediction 贪心

HDU 1338 Game Prediction 贪心

左眼皮跳跳 1138

HDU 2037 今年暑假不AC

贪心 HDU 2037 今年暑假不AC

左眼皮跳跳 1077

Hot Days Codeforces Round #132 (Div. 2) D(贪心)

Description The official capital and the cultural capital of Berland are connected by a single road running through n regions. Each region has a unique climate, so the i-th (1 ≤ i ≤ n) region has

左眼皮跳跳 1057

ZOJ 3019 Puzzle

贪心 ZOJ 3019 Puzzle

左眼皮跳跳 987

zoj 1543 贪心

zoj 1543 Stripies 贪心

左眼皮跳跳 926

POJ 1700 Crossing River(贪心)

V - Crossing River Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1700 Description A group of N people wishes to go across

左眼皮跳跳 795

zoj 2921 Stock(贪心)

Optiver sponsored problem. After years of hard work Optiver has developed a mathematical model that allows them to predict wether or not a company will be succesful. This obviously gives them a grea

左眼皮跳跳 791

CSU 1603 Scheduling the final examination(贪心)

1603: Scheduling the final examination Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 58  Solved: 18 [Submit][Status][Web Board] Description For the most of the university students,what t

左眼皮跳跳 764

HDU 1789 贪心

Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in

左眼皮跳跳 711
上一篇: HDU 1043 Eight(bfs+康托展开)
下一篇: HDU 1429 胜利大逃亡(续)(bfs)
左眼皮跳跳~
博客等级 码龄13年 17粉丝 400原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值