本题是利用counting sort的思想去解题。

注意本题,好像利用直接排序,然后查找rank是会直接被判WA的。奇怪的推断系统。

由于分数值的范围是0到100,很小,而student 号码又很大,故此天然的须要利用counting sort的情况。

#include <stdio.h>
#include <string.h> const int MAX_N = 101;
int arr[MAX_N]; int main()
{
int Jackson, JackScore, stu, score;
while (scanf("%d", &Jackson) != EOF)
{
memset(arr, 0, sizeof(int)*MAX_N);
while (scanf("%d %d", &stu, &score) && stu)
{
if (stu == Jackson) JackScore = score;
arr[score]++;
}
int rank = 1;
for (int i = 100; i >= 0; i--)
{
if (i == JackScore)
{
printf("%d\n", rank);
break;
}
rank += arr[i];
}
}
return 0;
}

HDU 1718 Rank counting sort解法的更多相关文章

  1. hdu 1718 Rank

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1718 Rank Description Jackson wants to know his rank ...

  2. HDOJ(HDU) 1718 Rank(水题、、、)

    Problem Description Jackson wants to know his rank in the class. The professor has posted a list of ...

  3. HDU 1718 Rank (排序)

    题意:给你n个学号和成绩,并且给定一个学号,让找这个学号是多少名. 析:用个结构体,按成绩排序,然后找那个学号,这个题有一个小坑,那就是并列的情况, 可能并列多少名,这个要考虑一下,其他的easy! ...

  4. HDU 1718 Rank 排序

    解题报告:给一个班的学生的分数排序,然后判断Jack在他们班级的排名是多少,并且有如下规定,若多个人的分数相同,则他们的排名也 是相同的.说白了就是问这个班上分数比Jack高的人数有多少个,如果有n个 ...

  5. find out the neighbouring max D_value by counting sort in stack

    #include <stdio.h> #include <malloc.h> #define MAX_STACK 10 ; // define the node of stac ...

  6. ACM: hdu 1811 Rank of Tetris - 拓扑排序-并查集-离线

    hdu 1811 Rank of Tetris Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & % ...

  7. counting sort 计数排序

    //counting sort 计数排序 //参考算法导论8.2节 #include<cstdio> #include<cstring> #include<algorit ...

  8. 41. First Missing Positive(困难, 用到 counting sort 方法)

    Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] ...

  9. 《算法导论》——计数排序Counting Sort

    今天贴出的算法是计数排序Counting Sort.在经过一番挣扎之前,我很纠结,今天这个算法在一些scenarios,并不是最优的算法.最坏情况和最好情况下,时间复杂度差距很大. 代码Countin ...

随机推荐

  1. Angularjs中input的指令和属性

    建议添加 novalidate属性(可无值)到form标签上,这样可以保证在表单不合法的情况下阻止浏览器继续提交数据. 可以给表单元素 input 添加 required 属性(可无值),让该表单成为 ...

  2. Android反编译教程

    本文摘自 http://blog.csdn.net/ithomer/article/details/6727581 本文Android反编译教程,测试环境: Win7 Ultimate x64 Ubu ...

  3. Codeforces Round #221 (Div. 2) C. Divisible by Seven(构造 大数除法 )

    上几次的一道cf题. 题目:http://codeforces.com/contest/376/problem/C 性质: (4)a与b的和除以c的余数(a.b两数除以c在没有余数的情况下除外),等于 ...

  4. 两个STL网址 总结的很好 && c++堆的网址

    http://www.cnblogs.com/bigcat814/ http://blog.sina.com.cn/s/blog_7065a9de010154ve.html 堆 http://www. ...

  5. freemarker跳出循环

    break语句跳出当前循环,如下: <#list table.columns as c>             <#if c.isPK>                 &l ...

  6. 结构体buf_chunk_t

    /** Buffer pool chunk comprising buf_block_t */ typedef struct buf_chunk_struct buf_chunk_t; /** A c ...

  7. textview的上下滑动效果

    1.xml文件中 <TextView    …    android:scrollbars="vertical"  ../> 2.java文件中 textview.se ...

  8. GDI+ 学习记录(26): 显示图像 - Image

    //显示图像 var   g: TGPGraphics;   img: TGPImage; begin   g := TGPGraphics.Create(Self.Canvas.Handle);   ...

  9. HDU 1078 FatMouse and Cheese 记忆化搜索DP

    直接爆搜肯定超时,除非你加了某种凡人不能想出来的剪枝...555 因为老鼠的路径上的点满足是递增的,所以满足一定的拓补关系,可以利用动态规划求解 但是复杂的拓补关系无法简单的用循环实现,所以直接采取记 ...

  10. Datatable转成Json方式两则

    1, Asp.net C# 使用Newtonsoft.Json 实现DataTable转Json格式数据 1.这里下载:http://www.newtonsoft.com/products/json/ ...