poj 3320 Jessica's Reading Problem(尺取法)

AutoCAD 2024 Mac版安装激活教程:从下载到破解一站式解决方案 本文提供AutoCAD 2024 Mac版的详细安装与优化指南,包括系统要求检查、下载安装流程、常见问题解决方案及性能优化设置。特别介绍了如何应用最新补丁和Update保持软件性能,帮助用户顺利完成从安装到破解的全过程。 阅读详情
  1. 题意:为了准备考试,Jessica开始读一本很厚的课本。要想通过考试,必须把课本中所有的知识点都掌握。这本书总共有P页,第i页恰好有一个知识点ai(每个知识点都有一个整数编号)。全书中同一个知识点可能会被多次提到,所以她希望通过阅读其中连续的一些页把所有的知识点都覆盖到。给定每页写到的知识点,请求出要阅读的最少页数。
  2. problem link:http://poj.org/problem?id=3320
  3. 尺取法应用题目

AC code:

#include<iostream>
#include<set>
#include<map>
using namespace std;
const int N=1e6+6;
int n,a[N];
void solve(){
    set<int>s;
    for(int i=0;i<n;i++)s.insert(a[i]);
    int cnt=s.size();
    int x=0,y=0,num=0,res=n;
    map<int,int>mp;
    while(1){
        while(num<cnt&&y<n)if(mp[a[y++]]++==0)num++;
        if(num<cnt)break;
        res=min(res,y-x);
        if(--mp[a[x++]]==0)num--;
    }
    cout<<res<<endl;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;for(int i=0;i<n;i++)cin>>a[i];
    solve();
}
跟着团子学SAP CO:揭秘结果分析码在项目结算中的实战应用(一)KKA2/CJ88 本文深入解析了SAP CO模块中结果分析码在项目结算中的核心作用。以KKA2(方法10)和事务代码CJ88为例,详细阐述了如何在项目完工后一次性确认收入的场景下,通过结果分析功能实现收入与成本的精准匹配,将项目成本暂估为在制品,确保各期利润的准确反映。 阅读详情

相关推荐

软硬件协同设计的大小端问题

缘起 最近需要在soc系统内做协处理器,加速AES加密运算,寄存器一次读取32bit,AES一次处理128bit,因此在数据拼接的时候,需要考虑大小端的问题,特来记录一番。 一、什么是大小端 大小端的问题发生在寄存器和内存间传递数据,这点非常重要,很多地方简单地说是数据存储方式,其实不准确。追根溯源,大小端问题是在设计load,store指令的时候考虑的,因此本质是寄存器和内存交互的问题,其他地方不会发生。 比如c语言里定义一个变量int a=ox1234,那么查看在线汇编平台的对应汇编代码: # 给2号寄

http://www.icfgblog.com/ 613

POJ3320---Jessica's Reading Problem(尺取法)

DescriptionJessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all

Alex 1120

GD32F303实战:用定时器4触发ADC2+DMA,实现10ms精准采样1024点的完整流程

本文详细介绍了在GD32F303微控制器上使用Timer4触发ADC2配合DMA传输,实现10ms精准采样1024点的完整方案。从硬件架构设计、时钟树配置到定时器参数计算,提供了完整的工程实现流程和常见问题排查方法,适用于工业传感器监测等高实时性场景。

weixin_29194693的博客 433

Poj 3320 Jessica's Reading Problem(尺取法)

做这题的时候因为忽视了一个条件而吃了一发RE,下面先把RE代码和AC代码都贴出来,然后再进行分析。 RE代码: #include #include #include using namespace std; int n , a[1000005] , b[1000005] ; int main(void){ while ( scanf ("%d",&n ) != E

Stupid_Turtle的博客 377

Python开发者必看:5分钟搞定Gemini API的3种调用方式(含代码示例)

本文为Python开发者详细介绍了三种高效调用Gemini API的核心方式:基础同步调用、流式调用和聊天模式,并涵盖多模态应用等高级特性。通过清晰的代码示例和实战场景分析,帮助开发者快速掌握Gemini API的集成与优化,提升AI应用开发效率。

g8f9d0s1a2的博客 1122

【Docker】如何让docker容器正常使用nvidia显卡

描述了如何在docker容器中使用英伟达显卡的过程和问题解决方法。

NameLoadingFailed的博客 8372

POJ_3061 && POJ_3320 (尺取法)

题意1:给定长度为n的数列整数A0,A1,A2……An-1以及整数S。求出总和不小于S的连续子序列的长度的最小值。如果解不存在,则输出0。 题意2:为了准备考试,Jessica开始读一本很厚的课本。要想通过考试,必须把课本中所有的知识点都掌握。这本书共有P(1<=P<=10^6)页,第i页恰好有一个知识点Ai(每个知识点都有一个整数编号)。全书中同一个知识点可能会被多次提到,所以她希望通过阅读其中连续的一些页把所有的知识点都覆盖到。给定每页写到的知识点,请求出要阅读的最少页数。

一点也不二 1708

基于Cohesive单元的二维水力压裂(二)

部件 2D-deformabel-shell 尺寸100 矩形工具(-20,-20)(20,20) 刨分:预知cohesive单元&定位注液点位置,定义全局网格尺寸0.2 X方向采用过渡网格,向中间加密。指定网格类型:CPE4P,指定单元类型,COH2D4P,粘性正则化系数:0.0001 材料属性 材料1 弹性模量10e9,泊松比0.25,渗透率1e-7,孔隙比0.1,液体比重...

s0302017的博客 1598

【C++心路历程26】考试复习【尺取法】poj3320

【问题描述】   为准备考试,Jessica开始阅读一本很厚的课本。要想通过考试,必须把课本中所有知识点都掌握。这本书总共有P页,第i页恰好有一个知识点a[i](每个知识点都有一个整数编号)。全书中同一个知识点可能会被多次提到,所以她希望通过阅读其中连续的一些页把所有的知识点都覆盖到。给定每页写到的知识点,请求出要阅读的最少页数。 【输入格式】   第一行一个整数P,表示书本的总页数。接下来的一

ctf109的博客 568

ck3m多轴运动控制器笔记1:电机的配置与注意事项

利用PMAC(CK3M)运动控制器来实现对电机的控制,对具体的配置流程和注意事项讲解

p975468132的博客 4641

复旦微实现串口在线升级BOOT.BIN

将该 demo 生成的 app(升级用)和 fsbl、最简化 bit 文件(可选)打包成 BOOT.BIN,作为 golden image 烧写在 qspi flash 偏移 0 地址开始的位置,其中最简化 bit 文件为在线升级功能提供必要的物理通道(如果不需要,可以不打包该文件),golden image 一旦发布基本不需要进行升级,由该 golden image 负责和上位机进行通信交互,完成业务 app、业务 bit 文件、uboot 以及操作系统 image 等文件在线升级,在qspi flash

wangjie36的博客 3174

POJ 3320 Jessica's Reading Problem(尺取)

Description 某人读一本书,要看完所有的知识点,这本书共有P页,第i页恰好有一个知识点ai,(每一个知识点都有一个整数编号)。全书同一个知识点可能会被提到多次,他希望阅读其中一些连续的页把所有知识点都读到,给定每页所读到的知识点,求最少的阅读页数 Input 第一行一个整数为书页数P,第二行P个整数为每页的知识点,每个数字表示一个知识点 Output 输出最少阅读页数 Sam

ZSQ 819

TI硬件笔试面试题型解析上

摘要: 本专栏聚焦大厂硬件笔试面试题解析,当前第14期以德州仪器(TI)为例,涵盖模拟电路与数字电路核心考点。模拟电路部分涉及最大功率传递定理、运放设计(虚短/虚断)、共模抑制比(CMRR)及高频PCB信号完整性;数字电路包括CMOS与TTL对比、建立/保持时间、竞争冒险消除、D触发器分频及“线与”逻辑实现。文章强调通过例题掌握解题方法与知识点,助力读者应对硬件工程岗位的笔试与面试挑战,附常见考点总结与实用建议。全文注重理论与实践结合,提供典型题型解析与设计思路。(150字)

启芯硬件的博客 951

poj3320Jessica's Reading Problem—尺取法(java)

题目链接 大意:给序列数字,找出最小子序列,包含所有的元素类型。例如 5 1 8 8 8 1 输出2,因为1 8就包含了所有元素 思路:尺取法 这个和裸的尺取优点不同的是,他需要一个map来维护判断而不是sum维护判断。在右侧从左向右遍历的同时,用一个map<Integer,Integer>来维护元素,map.keyset()就可以判断是否包含所有元素,数值用来判断改元素出现次数是否...

bigsai 3022

深度学习工具包 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")

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

POJ3320 Jessica's Reading Problem 尺取法

题目链接:http://poj.org/problem?id=3320 题目大意:一本书上有n个知识点,这本书一共有p页,每页一个知识点(每个知识点有一个唯一的整数编号),全书中同一知识点可能会被多次提到,现在希望通过阅读其中连续的一些页码把所有的知识点都覆盖到。给出每页写到的知识点,求出最少需要阅读的页数。 分析:我们假设从某一页(第s页)开始阅读,为了覆盖所有的知识点需要阅

AC_Gibson的专栏 567

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

POJ - 3320 Jessica's Reading Problem(尺取法)

题意:为了准备考试,Jessica开始读一本书,书总共有P页,第i页有一个知识点ai,同一个知识点可能会出现多次,她希望读书中一段连续的页数来掌握所有的知识点,请求出需要读的最少的页数。 分析:我们用尺取法来求解。 (1).初始化s=t=num=0。 (2).如果t小于P,且num小于n(所有知识点个数),就一直增加t,如果出现新的知识点,则num++。 (3).如果num小于n,退出。否则更新res。 (4).count[s]--,如果这个知识点不再有出现,则num--,s++。回到(2)。

luciozhang的博客 1526

POJ 3320 Jessica's Reading Problem 尺取法

Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18385   Accepted: 6360 Description Jessica's a very lovely girl woo...

pxlsdz的博客 464

POJ 3320 · Jessica's Reading Problem【尺取法】

尺取法,难度中等。

张天枭の博客 458

POJ 3320 Jessica's Reading Problem 【尺取法】

Jessica's Reading Problem Description Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to

博客已搬迁到http://www.cnblogs.com/cniwoq/ 278

poj3320 Jessica's Reading Problem 尺取法

http://poj.org/problem?id=3320 #include &lt;iostream&gt; #include &lt;algorithm&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;set&gt; #include &lt;map&gt; using namespace std; c...

skykone1的博客 210

Jessica's Reading Problem(POJ3320【尺取法】)

Jessica's a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas incl...

ZepngLin的博客 317

POJ3320 Jessica's Reading Problem 尺取法

Jessica’s Reading Problem、 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22716 Accepted: 7687 Description Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem....

lifehappy 349

[尺取法] poj3320 Jessica's Reading Problem

Jessica’s Reading Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8531 Accepted: 2732 DescriptionJessica’s a very lovely girl wooed by lots of boys. Recently she has a pr

童凌的技术博客 656

poj 3320 Jessica's Reading Problem 【尺取法+STLmap set】

Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7893   Accepted: 2529 Description Jessica's a very lovely girl wooed by lots of

世界很大 1060

POJ3320 Jessica's Reading Problem【尺取法】

  Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12441   Accepted: 4234   Description Jessica's a very lovely girl wooed by lots of boys. Re...

海岛Blog 1441

Jessica's Reading Problem POJ - 3320(尺取法)

Jessica’s a very lovely girl wooed by lots of boys. Recently she has a problem. The final exam is coming, yet she has spent little time on it. If she wants to pass it, she has to master all ideas incl...

starlet_kiss的博客 330

POJ 3320 Jessica's Reading Problem(尺取法+STL)

Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18206   Accepted: 6290 Description Jessica's a very lovely girl wooed by lots of boys. Recently...

bingongzi的博客 372
上一篇: poj 3061 Subsequence (尺取法)
下一篇: Educational Codeforces Round 49 (Rated for Div. 2)A. Palindromic Twist
图南1204
博客等级 码龄9年 21粉丝 118原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值