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.. 可是我想多了. 将所有状态全部求出,排序后暴力判断即可. (水题有 ...
随机推荐
- Peeking Iterator 解答
Question Given an Iterator class interface with methods: next() and hasNext(), design and implement ...
- 数字图像处理之sobel边缘检测
在前两部文章介绍了几种边缘检测算法,和位图的内存结构.如果对前两篇文章已经理解透彻 了,那么本文将带你进入数字图像处理的世界. 本文通过C代码实现基本的sobel边缘检测,包括8个方向和垂直方向: 代 ...
- Lake Counting (POJ No.2386)
有一个大小为N*M的园子,雨后积起了水,八连通的积水被认为是链接在一起的求出园子里一共有多少水洼? *** *W* *** /** *进行深度优先搜索,从第一个W开始,将八个方向可以到达的 W修改为 ...
- MongoDB 复制
副本集:简单说,副本集就是有自动故障恢复功能的主从集群.主从集群和副本集最为明显的区别:副本集没有固定的“主节点”.整个集群会选出一个主节点.当其不能工作时,变更到其他节点.二者看起来非常相似:副本集 ...
- 二十七、Java图形化界面设计——容器(JFrame)
摘自http://blog.csdn.net/liujun13579/article/details/7756729 二十七.Java图形化界面设计--容器(JFrame) 程序是为了方便用户使用的, ...
- Android学习总结——文件储存
Android中文件存储的操作: 1.Activity的openFileOutput()方法可以把数据输出到文件中2.创建的文件保存在/data/data/<package name>/f ...
- CSS清除浮动_清除float浮动
2.clear:both清除浮动为了统一样式,我们新建一个样式选择器CSS命名为“.clear”,并且对应选择器样式为“clear:both”,然后我们在父级“</div>”结束前加此di ...
- apache如何在虚拟主机中实现用户验证
1,在相应的虚拟主机配置文件段,加入<Directory /data/www.admin.php> AllowOverride AuthConfig ...
- 《JavaScript 闯关记》之语句
表达式在 JavaScript 中是短语,那么语句就是整句命令.表达式用来计算出一个值,语句用来执行以使某件事发生.从本质上看,语句定义了 JavaScript 中的主要语法,语句通常使用一或多个关键 ...
- Debian 使用杂记(一)
前几天又冲动的把系统换成Linux了,最开始接触Linux是2010年,那时候买了个本本,预装的是ubuntu8.10,自此知道除了windows原来还有其它操作系统. 不记得什么时候开始知道ubun ...