Test instructions: give you n a school number and grade, and given a school number, let's find this number is how many names.
Analysis: Use a structure, according to the grade, and then find that school number, the problem has a small pit, that is the case of juxtaposition,
How many names may be tied, this one to consider, the other easy!
The code is as follows:
#include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector > #include <cstring> #include <map> #include <cctype>using namespace Std;const int maxn = + 5;stru CT node{ int id, score; BOOL operator < (const node &p) Const { return score > P.score; }}; Node A[maxn];int main () {// freopen ("In.txt", "R", stdin); int ID; while (scanf ("%d", &id) = = 1) { int indx = 0; while (true) { scanf ("%d%d", &a[indx].id, &a[indx].score); if (!a[indx].id) break ; ++indx; } Sort (A, a+indx); for (int i = 0; i < indx, ++i) if (a[i].id = = ID) {for (int j = i; j >= 0;--j) if (a[j].score! = A[i].sc Ore) { printf ("%d\n", j+2); break; } break; } } return 0;}
HDU 1718 Rank (sort)