当前位置:网站首页>Contest3145 - the 37th game of 2021 freshman individual training match_ D: Ranking
Contest3145 - the 37th game of 2021 freshman individual training match_ D: Ranking
2022-07-04 02:34:00 【This question AC sleep again】
//
problem D: ranking
The time limit : 1.000 Sec Memory limit : 128 MB
Title Description
Ningbo primary school students finished the programming competition in Zhenhai middle school , The teachers approved the success of all the students performance , Grades are ranked from high to low , The same grades are ranked from low to high by grade ( notes : It's pure fiction , Don't enter seat ). Now the organizer wants to know the top students of each ranking , Several students are below his grade ( she ).
Input
There are several lines : The first 1 Line has only one positive integer n(1<=n<=200), Indicates the number of students participating . The first 2 To the first n+1 Lines in total n That's ok , Each line has two positive integers s(0<=s<=400),g(1<=g<=6). Among them the first i+1 First number of rows s It means the first one i Results of students , The first i+1 The second number in the row g It means the first one i Grade of students .
Output
The output file paiming.out Yes n That's ok , There is only one positive integer per line , Among them the first i Number of rows k Indicates rank i Students of There is k Students rank higher than him ( she ) high , And the grade is higher than him ( she ) low .
The sample input Copy
5
300 5
200 6
350 4
400 6
250 5
Sample output Copy
0
0
1
1
3
//
#include<bits/stdc++.h>
using namespace std;
const int MAXN=222;
typedef struct student
{
int s,g;
}T;
T a[MAXN];
bool cmp( T x,T y )
{
if( x.s>y.s ) return true;
else if( x.s==y.s )
{
if( x.g<=y.g ) return true;
else return false;
}
else return false;
}
int main()
{
int n,s,g,i,j,ans;
while( ~scanf("%d",&n) )
{
for( i=0;i<n;i++ ) scanf("%d%d",&a[i].s,&a[i].g);
sort( a,a+n,cmp );
for( i=0;i<n;i++ )
{
ans=0;
for( j=0;j<i;j++ ) if( a[j].g<a[i].g ) ans++;
printf("%d\n",ans);
}
}
return 0;
}
边栏推荐
- What is the intelligent monitoring system of sewage lifting pump station and does it play a big role
- A. ABC
- C learning notes: C foundation - Language & characteristics interpretation
- 14. Process time
- Global and Chinese market of small batteries 2022-2028: Research Report on technology, participants, trends, market size and share
- The automatic control system of pump station has powerful functions and diverse application scenarios
- LV1 previous life archives
- Dans la recherche de l'intelligence humaine ai, Meta a misé sur l'apprentissage auto - supervisé
- WP collection plug-in free WordPress collection hang up plug-in
- The difference between int (1) and int (10)
猜你喜欢
FRP intranet penetration
Pytoch residual network RESNET
Redis transaction
High level application of SQL statements in MySQL database (I)
Yyds dry goods inventory override and virtual of classes in C
Node solves cross domain problems
From the 18th line to the first line, the new story of the network security industry
Advanced learning of MySQL -- Application -- storage engine
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
Example 073 square sum value judgment programming requires the input of a and B, if a ²+ b ² If the result of is greater than 100, a is output ²+ b ² Value, otherwise output the result of a + B.
随机推荐
LV1 Roche limit
Unity knapsack system (code to center and exchange items)
[untitled] the relationship between the metauniverse and digital collections
LV1 previous life archives
17. File i/o buffer
Gee import SHP data - crop image
MySQL advanced SQL statement (1)
Push technology practice | master these two tuning skills to speed up tidb performance a thousand times!
VRRP+BFD
Node solves cross domain problems
Latex tips slash \backslash
1189. Maximum number of "balloons"
What are the main investment products of bond funds and what are they
Pytoch residual network RESNET
Li Chuang EDA learning notes 13: electrical network for drawing schematic diagram
Keep an IT training diary 054- opening and closing
Introduction to graphics: graphic painting (I)
Advanced learning of MySQL -- Application -- storage engine
A fan summed up so many interview questions for you. There is always one you need!
Learn these super practical Google browser skills, girls casually flirt