Codeforces VK Cup 2012 Qualification Round 1 / 158A Next Round(模拟)

【愚公系列】《AIGC辅助软件开发》041-如何使用 AI技术提升工作效率:AI辅助软件架构师实践 在数字化转型的浪潮中,软件架构师作为技术团队的核心,承载着系统设计与架构优化的重要责任。然而,随着项目复杂度的增加和技术环境的变化,架构师面临着前所未有的挑战。幸运的是,人工智能(AI)技术的迅猛发展为这一行业带来了新的机遇,帮助架构师提升工作效率、优化决策过程,并改善团队协作。本文将深入探讨AI如何辅助软件架构师的实际工作,具体分析AI在需求分析、架构设计、代码生成、测试和优化等环节的应用。 阅读详情

A. Next Round
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules.

A total of n participants took part in the contest (n ≥ k), and you already know their scores. Calculate how many participants will advance to the next round.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 50) separated by a single space.

The second line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 100), where ai is the score earned by the participant who got the i-th place. The given sequence is non-increasing (that is, for all i from 1 to n - 1 the following condition is fulfilled: ai ≥ ai + 1).

Output

Output the number of participants who advance to the next round.

Sample test(s)
input
8 5
10 9 8 7 7 7 5 5
output
6
input
4 2
0 0 0 0
output
0
Note

In the first example the participant on the 5th place earned 7 points. As the participant on the 6th place also earned 7 points, there are 6 advancers.

In the second example nobody got a positive score.


注意特判。


完整代码:

/*30ms,0KB*/

#include<cstdio>

int main()
{
	int n, k, a, i, now;
	scanf("%d%d", &n, &k);
	for (i = 1; i <= n; ++i)
	{
		scanf("%d", &a);
		if (a == 0)
		{
			printf("%d", i - 1);
			return 0;
		}
		if (i == k)
		{
			now = a;
		}
		else if (i > k)
		{
			if (a != now)
			{
				printf("%d", i - 1);
				return 0;
			}
		}
	}
	printf("%d", i - 1);
	return 0;
}



如何使用C#自带的GDI+双缓冲类BufferedGraphics实现双缓冲功能 小白摸索着编写一个上位机界面,将遇到的问题及解决方法记录下,以供后来的小白使用哈。这篇文章解决的问题是在绘图时候的闪烁问题。其中网上有些介绍的设置控制方式controlstyle的方法,这个方法我的理解是比较适合于在一个完整的窗口当中绘图。如果要在一个窗口当中的内部容器或者控件内画图的话就不太适合,通常按照前述的方法设置后没有任何效果。对于在窗口内部的绘图的来说,比较有效的方法是在内存当中开辟一块 阅读详情

相关推荐

Enterprise Architect 中文经典教程

本文使用到的EA工程文件下载 一、Enterprise Architect简介 Enterprise Architect是一个对于软件系统开发有着极好支持的CASE软件(Computer Aided Software Engineering)。EA不同于普通的UML画图工具(如VISIO),它将支撑系统开发的全过程。在需求分析阶段,系统分析与设计阶段,系统开发及部署等方面有着强大的支持,...

2万+

A. Next Round

time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output "Contestant who earns a score equal to or greater than the k-th

无知的我 2845

嘉立创EDA实战:从点亮第一盏灯到完成首块PCB

本文详细介绍了使用嘉立创EDA从点亮第一盏LED灯到完成首块PCB的全过程。通过实战案例分享,包括原理图绘制、PCB设计、DRC检查、覆铜操作等关键步骤,帮助电子设计爱好者快速掌握嘉立创EDA的使用技巧,并避免常见的设计错误。

weixin_30314793的博客 373

158A - Next Round

A. Next Round time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output“Contestant who earns a score equal to or greater than the k-th place

Cai_Haiq的博客 743

【移远EG800K-CN】从AT指令到MQTT实战:4G模块云端通信全解析

本文详细解析移远EG800K-CN 4G模块的AT指令应用与MQTT云端通信实战。从硬件连接到网络配置,再到MQTT协议的数据上报与命令接收,提供了完整的物联网通信解决方案,帮助开发者快速实现设备与云端的稳定数据交互。

o1p2q3r的博客 559

实战MSP-M0G3507与陶晶驰串口屏的通信协议解析

本文详细解析了MSP-M0G3507微控制器与陶晶驰串口屏的通信协议实现。内容涵盖串口配置、协议帧结构、数据校验机制及ASCII协议实战代码,重点介绍了陶晶驰串口屏的指令集应用和调试技巧,为嵌入式开发提供可靠的串口通信解决方案。

h9j8k7l6m5n的博客 867

A. Next Round【难度: 水题 / 知识点: 模拟】

https://codeforces.com/problemset/problem/158/A #include<bits/stdc++.h> using namespace std; const int N=1e5+10; int n,m,cnt,s[N]; int main(void) { cin>>n>>m; for(int i=1;i<=n;i++) cin>>s[i]; int temp=s[m]; for(int i=1;i<.

bettle_king的博客 239

《Python入门到精通》函数详解

函数就是一段「封装」起来的「代码」,目的是提高代码的「模块性」和「复用性」。 2、函数的参数 2.1、变量的就近原则 2.2、传递参数 2.3、形参和实参 2.4、位置参数 2.5、缺省参数 2.6、可变类型和不可变类型 2.7、关键字参数 3、匿名函数 4、函数的返回值

wangyuxiang946的博客 1万+

VK Cup 2012 Qualification Round 1 A题

这题要仔细阅读题目的意思!就是这就句话“"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an e

傻笨 961

Transformer 面试题及详细答案120道(1-10)-- 基础概念

本文总结了Transformer模型的10个常见面试问题及答案,涵盖了其核心结构、创新点、工作机制等关键知识点。主要内容包括:Transformer的自注意力机制和多头注意力机制创新点,相比RNN/CNN的优势,模型在《Attention Is All You Need》论文中的提出背景,以及Encoder-Decoder协同工作流程等。重点解析了位置编码的作用、长距离依赖处理能力、与传统注意力机制的区别等核心问题。每个问题都给出了简明扼要的专业解答,适合作为Transformer相关面试准备的参考资料。

大剑师兰特的GIS世界 849

[Dify] 如何构建一个带评分功能的 Dify AI 教练系统

本文介绍如何利用Dify开源平台构建具备自动评分功能的AI教练系统。系统通过Prompt设计AI教练角色,使用OpenAPI定义评分工具接口,结合工作流编排实现提问、回答收集、评分和反馈的全流程。文章详细讲解了从AI教练身份设定、多维度评分标准设计到前端可视化展示的实现方法,并提供了可扩展建议,适用于语言训练、面试模拟等多种场景。该系统展示了Dify平台在构建智能化评估应用方面的优势,实现零代码开发专业AI教练解决方案。

技术小甜甜:传播可落地技术,帮助个人和企业降低解决真实场景问题的成本 333

codeforces 158A - Next Round (c语言)

158A - Next Round (c语言)

ectfgd的博客 303

华为od 面试八股文_C++_01_含答案

华为od 面试八股文_C++_01_含答案

MISAYAONE的博客 5591

problem-158A-Next Round-codeforces

题目 "Contestant who earns a score equal to or greater than thek-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest rules. A total ofnparticipants took part in the con...

weixin_52538235的博客 629

Devexpress16.2.6破解工具

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

CF——Next Round

"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt from contest

空白页 874

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

关于一些初级ACM竞赛题目的分析和题解(一)。

关于一些初级ACM竞赛题目的分析和题解(一)   故事发生在在2017年年底,受我的室友cy1999巨巨的影响下,第一次接触到ACM竞赛,也是作为一名编程小白,第一次感受到编程语言的魅力。用竞赛这种形式来提高自己的编程能力,虽说不上是曲径通幽,但也不失为一种好方法。废话少说,上题。 A. Football time limit per test 2

monster_ayb的博客 3969

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

Codeforces 158A-Next Round

思路:得分非正数直接跳过,因为序列是非增的,所以第k个数及之前的正数直接计算在内,第k个数之后的与第k个数相等的可计算在内。positive 正数的 excerpt 节选 non-increasing 非增。

ywzdcj的博客 197

codeforces 158A Next Round(水题)

A. Next Round 点击打开题目 time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output "Contestant who earns a score equal

1460

题解 CF158A 【Next Round】

本题解提供一种桶的写法 思路: 先定义个桶: int a[105]; 注意:桶的大小是根据 $a[i]$ 的数据范围来的,本题 $a[i]$ 最大只有100 把输入存到桶里: for(int i=1;i<=n;i++){ cin>>t; a[t]++; } 从大到小枚举,只要参赛人数一够就输出,结束: for(int i=100;i>=1;i--){ ...

houpingze的博客 375

158A Next Round

#include #include #include #include #include #include using namespace std; const int maxn = 60; int arr[maxn]; int main() { int ans = 0; int n, k; cin >> n >> k; for(int i = 1;

XDU_PYL的博客 532

【Codeforces 158A】Next Round

【链接】 我是链接,点我呀:) 【题意】 让你找到排名的前k名,并列的话,如果分数大于0那么就算晋级 问你最后有多少人可以晋级. 【题解】 按照题意模拟就好, 先按照a[max] = a[k]的规则找到下标的最大值max 然后依据a[max]==0的规则,一直减小这个max. 直到max变成0为止。 最后输出max就好了 【代码】 import java.util.S...

239

Next Round

文章目录一、Next Round总结 一、Next Round 本题链接:Next Round 题目: A. Next Round time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard output “Contestant who earns a score equal to or greater than the k-th place finisher’s s.

佛系更新 897

Codeforces——158A Next Round

小声BB 最近总是状态不好,不管是范围还是特例都有思考不周之处 题干 time limit per test:3 seconds memory limit per test:256 megabytes input:standard input output:standard output “Contestant who earns a score equal to or greater than the k-th place finisher’s score will advance to the next

真田伊廉的博客 531

VK Cup 2012 Qualification Round 1 A. Next Round

A. Next Round time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output "Contestant who earns a score equal to or greater...

weixin_34107739的博客 191

2013资格赛——Next Round

Description "Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score..." — an excerpt fr

Heu_Ice_Fire的专栏 678

模式匹配

模式匹配最基本的思想就是源字符串的每个字符和子串的每个字符进行比较, 其实现方法如下:  int Index(char* S, char* T, int slen,int tlen,int pos) { int i=pos,j=0; while(i { if (*(S+i) ==*(T+j)) { i++; j++; } else { i = i - j + 2; j

daiyier的专栏 1006
上一篇: DFS相关的一些模板
下一篇: Codeforces Beta Round #65 (Div. 2) / 71A Way Too Long Words(字符串操作)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值