【Codeforces 158A】Next Round
【链接】 我是链接,点我呀:)
【题意】
让你找到排名的前k名,并列的话,如果分数大于0那么就算晋级
问你最后有多少人可以晋级.
【题解】
按照题意模拟就好,
先按照a[max] = a[k]的规则找到下标的最大值max
然后依据a[max]==0的规则,一直减小这个max.
直到max变成0为止。
最后输出max就好了
【代码】
import java.util.Scanner;
public class Main {
public static int N = 50;
public static int n,k;
public static int a[];
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
a = new int[N+10];
n = in.nextInt();k = in.nextInt();
for (int i = 1;i <= n;i++) a[i]= in.nextInt();
int ma = k;
for (int i = k+1;i <= n;i++)
if (a[i]==a[k]) {
ma = i;
}
while (a[ma]==0 && ma>=1) ma--;
System.out.println(ma);
}
}
【Codeforces 158A】Next Round的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【51.27%】【codeforces 604A】Uncowed Forces
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 742C】Arpa's loud Owf and Mehrdad's evil plan
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【codeforces 546D】Soldier and Number Game
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 750B】New Year and North Pole
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 766D】Mahmoud and a Dictionary
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- linux设备驱动模型之Kobject、kobj_type、kset【转】
本文转载自:http://blog.csdn.net/fengyuwuzu0519/article/details/74838165 版权声明:本文为博主原创文章,转载请注明http://blog.c ...
- [模板]FWT
写起来和fft很像,这里放个板子. 代码: #include<iostream> #include<cstdio> #include<cmath> #include ...
- P3567 [POI2014]KUR-Couriers 主席树
这个题比一般主席树还要简单,但是用来练习主席树再好不过了,在这里我再放一下主席树板子. 代码: #include<iostream> #include<cstdio> #inc ...
- LVS上DR和NAT模式的缺陷
引言 相信一般的小公司用的最多的还是DR和NAT模式,关于DR和NAT模式的原理请看看下图,我们先从lvs的DR和NAT模式特性聊聊一些问题. 问题1.lvs的DR模式和NAT模式核心缺陷有哪些? D ...
- 14款形态各异的超时尚HTML5时钟动画
14款超时尚的HTML5时钟动画(附源码) 时钟动画在网页应用中也非常广泛,在一些个人博客中,我们经常会看到一些相当个性化的HTML5时钟动画.今天我们向大家分享了14款形态各异的超时尚HTML5 ...
- idea ssm项目移包报错问题
写完代码之后发现包结构太乱了 想要规划一下 结果报错 这里面的包路径都可以点进去,还是报找不到com.lf.company.entity.Business 后来发现是 在移动前和移动后都存在这个m ...
- $P2126 Mzc家中的男家丁$
problem #ifdef Dubug #endif #include <bits/stdc++.h> using namespace std; typedef long long LL ...
- Ambari架构及安装
不多说,直接上干货! 1.什么是Ambari? 2.Ambari项目是由哪几部分构成的? 3.Ambari系统架构是如何组成的? 前言 Hadoop集群的管控一直是一个热门的话题,对于这样的一个应用场 ...
- Mysql的事务、视图、索引、备份和恢复
事务 事务是作为单个逻辑工作单元执行的一系列操作,一个逻辑工作单元必须具备四个属性.即:原子性.一致性.隔离性.持久性,这些特性通常简称为ACID. 原子性(Atomicity) 事务是不可分割的 ...
- MySql(二):常见的那些个约束
今天总结一下mysql当中的常见约束吧! 那什么是约束呢?通俗点讲,约束就是限定指定字段的存放规则! ● 主键约束(Primary Key) ● 外键约束(Foreign Key) ● 非空约束(No ...