Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
Another programming contest is over. you got hold of the contest's final results table. the table has the following data. for each team we are shown two numbers: the number of problems and the total penalty time. however, for no team we are shown its final
Place.
You know the rules of comparing the results of two given teams very well. Let's say that teamASolvedPAProblems
With total penalty timeTAAnd
TeamBSolvedPBProblems
With total penalty timeTB.
TeamAGets a higher place than teamBIn
The end, if it either solved more problems on the contest, or solved the same number of problems but in less total time. In other words, TeamAGets
A higher place than teamBIn the final results 'table if eitherPALatency> latencyPB,
OrPASignature = SignaturePBAndTALatency <latencyTB.
It is considered that the teams that solve the same number of problems with the same penalty time share all corresponding places. More formally, let's say there is a groupXTeams
That solved the same number of problems with the same penalty time. Let's also say thatYTeams saved med better than the teams from this
Group. In this case all teams from the group share placesYLimit + limit 1,YLimit + limit 2 ,...,YRegion + RegionX.
The teams that were med worse than the teams from this group, get their places in the results table starting fromYRegion + RegionXBytes + bytes 1-th
Place.
Your task is to count what number of teams from the given list sharedK-Th place.
Input
The first line contains two integersNAndK(1 digit ≤ DigitKLimit ≤ limitNLimit ≤ limit 50 ).
ThenNLines contain the description of the teams:I-Th
Line contains two integersPIAndTI(1 digit ≤ DigitPI, Bytes,TILimit ≤ limit 50)
-The number of solved problems and the total penalty time ofI-Th team, correspondingly. All numbers in the lines are separated by spaces.
Output
In the only line print the sought number of teams that gotK-Th place in the final results 'table.
Sample test (s) Input
7 24 104 104 103 202 12 11 10
Output
3
Input
5 43 13 15 33 13 1
Output
4
Note
The final results 'table for the first sample is:
- 1-3 places-4 solved problems, the penalty time equals 10
- 4 place-3 solved problems, the penalty time equals 20
- 5-6 places-2 solved problems, the penalty time equals 1
- 7 place-1 solved problem, the penalty time equals 10
The table shows that the second place is shared by the teams that solved 4 problems with penalty time 10. There are 3 such teams.
The final table for the second sample is:
- 1 place-5 solved problems, the penalty time equals 3
- 2-5 places-3 solved problems, the penalty time equals 1
The table shows that the fourth place is shared by the teams that solved 3 problems with penalty time 1. There are 4 such teams.
Problem description: This question is mainly sorted according to the two conditions. However, you can combine the two conditions into one condition by assigning different weights. The score here is 50 to 1, this ensures that the number of questions occupies a large proportion. Then, find out how many digits are the same as the k-th digit.
#include<cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>using namespace std;int main(){int n, k, A[50], i, con=0, a, b;scanf("%d %d",&n,&k);for(i=0; i<n; i++){scanf("%d %d",&a,&b);A[i]=a*50-b;}sort(A,A+n);for(i=0; i<n; i++){if(A[i]==A[n-k]){con++;}}printf("%d\n",con);return 0;}