sort(水题)
sort
Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39400 Accepted Submission(s): 11450
3 -35 92 213 -644
Hint
请用VC/VC++提交
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN = ;
int a[MAXN];
int cmp(int x,int y){
return x > y;
}
int main(){
int n,m;
while(~scanf("%d%d",&n,&m)){
for(int i = ;i < n;i++){
scanf("%d",&a[i]);
}
sort(a,a + n, cmp);
for(int i = ; i < m;i++){
if(i)printf(" ");
printf("%d",a[i]);
}
puts("");
}
return ;
}
C# wa了:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections; namespace sort
{
class Program
{
static int input()
{
int x = , k = ;
int temp;
while (true)
{
temp = Console.Read();
if (temp >= '' && temp <= '')
break;
else if(temp == '-')
{
k = -;
temp = '';
break;
}
}
while (true)
{
x = x * + temp - '';
temp = Console.Read();
if (temp < '' || temp > '') break;
}
// Console.WriteLine("{0}",x * k);
return x * k;
}
static void Main(string[] args)
{
int n, m;
n = input();
m = input();
ArrayList arr = new ArrayList();
arr.Clear();
while (n-- > )
{
int x;
x = input();
arr.Add(x);
}
arr.Sort();
for(int i = ; i <= m; i++)
{
if (i != ) Console.Write(" ");
Console.Write("{0}",arr[arr.Count - i]);
}
Console.WriteLine();
//while (true) ;
}
}
}
sort(水题)的更多相关文章
- Codeforces Gym 100431D Bubble Sort 水题乱搞
原题链接:http://codeforces.com/gym/100431/attachments/download/2421/20092010-winter-petrozavodsk-camp-an ...
- CF451B Sort the Array 水题
Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory ...
- CF451C Predict Outcome of the Game 水题
Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- URAL - 1917 Titan Ruins: Deadly Accuracy(水题)
水题一个,代码挫了一下: 题意不好理解. 你去一个洞窟内探险,洞窟内有许多宝石,但都有魔法守护,你需要用魔法将它们打下来. 每个宝石都有自己的防御等级,当你的魔法超过它的防御等级时它就会被你打下来. ...
- 水题 ZOJ 3875 Lunch Time
题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...
- 水题 ZOJ 3869 Ace of Aces
题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...
- 【BZOJ】3850: ZCC Loves Codefires(300T就这样献给了水题TAT)
http://www.lydsy.com/JudgeOnline/problem.php?id=3850 题意:类似国王游戏....无意义.. #include <cstdio> #inc ...
- 【wikioi】1229 数字游戏(dfs+水题)
http://wikioi.com/problem/1229/ 赤裸裸的水题啊. 一开始我认为不用用完全部的牌,以为爆搜会tle.. 可是我想多了. 将所有状态全部求出,排序后暴力判断即可. (水题有 ...
随机推荐
- EXT JS 4.3 在线学习
官网地址:http://docs.sencha.com/extjs/4.1.3/ 相关示例:http://docs.sencha.com/extjs/4.1.3/#!/example Examples ...
- postgresql基本语句
preface,熟悉pgsql sql Language article disorder; 1,pgsql数据库控制台Cli(command line interface) help mannual ...
- android中通过自定义xml实现你需要的shape效果 xml属性配置
在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来解决.不过这种方式可能需要多个图片,比如一个按钮,需要点击时的式样图片,默认的式样图片,然后在写一个selector的 ...
- 总结FormsAuthentication的使用
一.先看一下使用FormsAuthentication做登录认证的用法 用法一: FormsAuthentication.SetAuthCookie(username, isPersistent); ...
- Java程序员面试题集(86-115)
摘 要:下面的内容包括Struts 2和Hibernate的常见面试题,虽然Struts 2在2013年6月曝出高危漏洞后已经显得江河日下,而Spring MVC的异军突起更加加速了Struts 2的 ...
- Android应用程序组件Content Provider在应用程序之间共享数据的原理分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6967204 在Android系统中,不同的应用 ...
- PHP在Windows下安装配置第一步
第一步就是下载和安装PHP解释器了: 1.下载Windows版本号的PHP解释器,下载地址:官方下载 我下载的是 VC11 x64 Thread Safe 这个以下的zip包 2.下载完毕后,解压到 ...
- notepad++和gcc搭建语言环境
1,工具: Notepad++:http://pan.baidu.com/s/1sjlXl6X MinGW:http://pan.baidu.com/s/1qWyQ3lq 2,安装notepad++ ...
- mysql1主多从配置
mysql一主多从的配置: 其实1主多从的配置与一主一从配置非常相似,现在主要讲讲一主多从的大概配置方法. 一, 1,master端开启binlog日志,并且设置server id=1. 2.重启服务 ...
- hadoop python and Twitter
http://www.wubiaoblog.com/archives/1159 http://blog.csdn.net/anbo724 http://f.dataguru.cn/forum.php? ...