Doing Homework again【暑期集训R题】【DP】【哈希】

从USB相机标定到Aruco码精准定位:基于aruco-ros的机器人视觉实践 本文详细介绍了基于aruco-ros的机器人视觉实践,从USB相机标定到Aruco码精准定位的全流程。通过实战案例和优化技巧,展示了Aruco码在机器人导航中的高精度位姿识别能力,帮助开发者快速实现毫米级视觉定位系统。 阅读详情

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 the homework after the deadline, the teacher will reduce his score of the final test. And now we assume that doing everyone homework always takes one day. So Ignatius wants you to help him to arrange the order of doing homework to minimize the reduced score.
InputThe input contains several test cases. The first line of the input is a single integer T that is the number of test cases. T test cases follow. 
Each test case start with a positive integer N(1<=N<=1000) which indicate the number of homework.. Then 2 lines follow. The first line contains N integers that indicate the deadlines of the subjects, and the next line contains N integers that indicate the reduced scores. 
OutputFor each test case, you should output the smallest total reduced score, one line per test case. 
Sample Input
3
3
3 3 3
10 5 1
3
1 3 1
6 2 3
7
1 4 6 4 2 4 3
3 2 1 7 6 5 4
Sample Output
0
3
5

    这道题的思维与DP的关系倒是不大,说实话,我觉得用到的贪心思想会多一些,之后的对于要写的作业的放置顺序会更加的贴近哈希算法。

    思路:我们能够得到这样的一串没有排过序的紊乱的截止日期与不做完就要扣的分数,我们要尽所能使得扣分少一些,那么,我想到的就是,把分数最高的开始,我们对于作业分数降序排列,而且让高分刚好掐在它的截止日期上,这样才能给后面的分数段留足空间,但遇到截止日期上刚好被其他数霸占了,那么说明这个数优先级要低,但又比剩下的数优先级高,遇到这种情况,我们把它往前提1,若不为空继续提1,但要是都满了,这个数就只能舍弃了。

完整代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
struct node
{
    int a,b;        //a指截止日期,b指扣分数
}k[1005];
int vis[1005];
bool cmp(node r1, node r2)
{
    return r1.b==r2.b?(r1.a>r2.a):(r1.b>r2.b);
}
int N;
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int sum=0;
        memset(vis, 0, sizeof(vis));
        scanf("%d",&N);
        for(int i=0; i<N; i++)
        {
            scanf("%d",&k[i].a);
        }
        for(int i=0; i<N; i++)
        {
            scanf("%d",&k[i].b);
        }
        sort(k, k+N, cmp);
        for(int i=0; i<N; i++)
        {
            for(int j=k[i].a; j>0; j--)
            {
                if(!vis[j])
                {
                    vis[j]=1;
                    break;
                }
                else if(j==1)
                {
                    sum+=k[i].b;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

第十届MathorCup高校数学建模挑战赛-B题:养老服务床位需求预测与运营模式研究 当养老床位数增加时存在的商机,提出了相应的养老服务床位的运营商业模式。就业的可能性,建立多目标规划模型,尽可能同时满足三方面的要求。务床位的需求、制定合理的养老服务床位发展规划,是构建和谐社会、幸福社会。问题一的床位需求与市场类型的分类结果,查找关于国内养老院的相关数据,探。求,又能持续发展养老事业,同时还能促进社会就业的养老服务床位运营的商业。养老服务床位数的增加能够带来的就业方面因素的影响,并对这些因素进行一个。你们的模型及其结论为科学依据,对政府管理部门针对养老床位规划提出合理的。 阅读详情

相关推荐

手把手教你玩转Infoseek舆情监测系统:从数据爬取到智能分析实战

别只会监测品牌名!一个有效的监测体系应该包括:// 完整的监测关键词策略brand: ["品牌名", "产品名", "缩写"],executives: ["CEO姓名", "高管姓名"],campaign: ["当前营销活动名称"],competitors: ["竞品A", "竞品B"],industry: ["行业通用关键词"],// 别忘了常见拼写错误和黑称defensive: ["常见的错误拼写", "用户起的黑称"]产品优化:从用户吐槽中发现改进点市场洞察。

2501_93332955的博客 780

贪心+堆维护,HDU1789Doing Homework again

贪心调度问题

EQUINOX1的博客 1049

量子-经典混合架构与动态QUBO建模

量子-经典混合架构与动态QUBO建模的结合,是当前量子计算与经典计算融合领域的前沿方向。通过将量子计算的并行性与经典计算的灵活性结合,该技术为解决复杂动态优化问题(如实时调度、金融投资组合优化、电力系统控制等)提供了全新的方法论。:将发电机组调度分解为QUBO(启停决策)与非QUBO(功率分配)子问题,通过3块ADMM协调;c_i(t) $随外部环境(如电力需求、市场价格)动态调整。量子-经典混合架构与动态QUBO建模的结合,标志着优化计算从。:每分钟根据市场波动调整QUBO的收益率-风险系数;

百态·数智思维 | 聚焦大数据、量化与未来AI 1341

ACM题解——贪心——调度问题

ACM题解——贪心——调度问题 题目描述 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 the homework after the deadline, the teacher will r

Biangbangbing的博客 1147

Android音频输出流实战:从AudioFlinger到HAL层的完整调用链解析

本文深入解析了Android音频输出流的完整调用链,从应用层的AudioTrack和AAudio API,到系统服务AudioFlinger的混音调度,最终抵达硬件抽象层(HAL)。文章结合实战经验,探讨了如何利用底层机制优化音频延迟、处理设备切换,并提供了性能调优与问题排查的具体方法,是开发高性能音频应用的实用指南。

weixin_29208327的博客 254

从零开始:在Ubuntu 22.04上配置Isaac Gym Preview 3环境(含常见错误解决方案)

本文提供了在Ubuntu 22.04系统上从零开始配置Isaac Gym Preview 3环境的完整实战指南。内容涵盖NVIDIA驱动安装、Conda环境搭建、CUDA与PyTorch版本精准匹配、Isaac Gym核心安装与验证,并重点介绍了针对四足机器人等复杂系统的强化学习训练环境配置、常见错误解决方案及性能调优技巧,旨在帮助开发者高效部署这一高性能物理仿真平台。

weixin_29048775的博客 400

英语题翻译13

Doing Homework | JXNUOJ 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 the homework after the deadline, the teacher will re

zanhhhhhh的博客 311

深度学习实战:基于YOLOv5/v8/v10的快递暴力分拣检测系统(完整版)

在电商物流高速发展的今天,快递包裹日均处理量已突破亿件级别。然而,快递分拣过程中的暴力抛扔行为不仅造成包裹损坏,更带来巨大的经济损失。据统计,每年因暴力分拣导致的快递破损投诉占总投诉量的30%以上。传统的人工监控方式存在疲劳、疏漏等问题,因此开发一套智能化的快递暴力分拣检测系统具有重要的现实意义。

YOLO 290

杭电OJ--Doing Homework again(纯C语言)

杭电OJ1789,贪心算法个人代码展示

jin_min的博客 1048

VIIRS-NPP夜间灯光遥感数据下载和预处理

右侧搜索框搜索“按掩膜提取”,提取出夜光影像中国区域。将其转换为Albers积投影和重采样到400m。点击右上角Export,选择shp格式。最后点export导出就行。点击复制按钮,来到这个。,ctrl + v粘贴。将小于0.3的值置为0。下载好月合成产品后,

热爱分享,热爱记录 1万+

C++程序无法正常启动(报0xc000007b错误)问题的详细排查

本文详细介绍了应用程序启动时遇到0xC000007B错误的排查过程。问题源于32位程序与64位运行时库的不匹配,以及缺少依赖的运行时库。通过分析系统日志、使用Windbg和检查程序位数,最终确定问题在于32位程序误引用了64位系统目录下的库文件。

dvlinker的技术专栏 1万+

杭电1789—Doing Homework again

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 ...

诗鸩的博客 310

硬核实战!Python爬虫从0到1完整版:爬取知乎热榜+回答内容(数据去重+Excel一键导出+避坑指南,零基础友好)

✔️ 适用人群:Python爬虫零基础、想练手实战爬虫、需要爬取知乎内容做数据分析、办公/学习素材整理的同学爬取知乎热榜全量数据(排名+标题+热榜链接+热度值) →自动跟进爬取每个热榜问题的回答内容(回答者昵称+赞同数+评论数+回答正文+发布时间) →数据清洗+智能去重→一键导出格式化Excel文件,所有功能一站式完成入门级难度,无复杂反爬破解、无分布式/代理池,纯requests请求+静态解析,新手能看懂、能运行、能修改;爬取速度快,热榜+回答全程仅需几十秒。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1468

HDU 1789-Doing Homework again(并查集+贪心)

Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 22901 Accepted Submission(s): 13208 Problem Description Ignatius has ju...

在读NLP硕士 425

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

acm之贪心算法题目5

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 t

Jancy的博客 1367

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

HDU-1789-Doing Homework again(贪心)

Doing Homework againProblem DescriptionIgnatius 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

lhc----- 476

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

hdu 1789 Doing Homework again

题目描述: 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 the homework af...

qq_43909874的博客 392

hdu - 1074(超级详细)

看了半天题解,感觉这道题好神奇,这种方法枚举真厉害!!题目:点此进入 Doing HomeworkIgnatius 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 hom

神回 4777

hdu 1789 Doing Homework Again!

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

捡起回忆碎片 618

Doing Homework again (贪心)

Doing Homework again 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.

ljyanjy 409

杭电 1789(贪心思维练习)

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 the homework after th...

PengWei Yang 279

第二周--贪心题解(J)

题J: 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 the homework after the deadline, the teacher will reduce his score of the

weixin_51934288的博客 377

HDU1074:Doing Homework-状态压缩DP

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

GDUFE_SSS 383

Doing Homework again(区间选点)

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 the ho

逝水流年轻染尘 897

贪心算法中一种类型的题(贪心)

1. 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 i...

wcxyky的博客 718

hud 1074 Doing Homework(状态压缩)

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 t

跟随内心的渴望 383
上一篇: FATE【暑期集训V题】【完全背包】
下一篇: How many ways【暑期集训T题】【DP】【记忆化搜索】
Wuliwuliii
博客等级 码龄9年 463粉丝 1080原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Wuliwuliii

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值