当前位置:网站首页>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;
}
边栏推荐
- Optimization theory: definition of convex function + generalized convex function
- The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
- Global and Chinese market of handheld melanoma scanners 2022-2028: Research Report on technology, participants, trends, market size and share
- Hamburg University of Technology (tuhh) | intelligent problem solving as integrated hierarchical reinforcement learning
- Career development direction
- Small program graduation project based on wechat reservation small program graduation project opening report reference
- Portapack application development tutorial (XVII) nRF24L01 launch C
- High level application of SQL statements in MySQL database (I)
- A fan summed up so many interview questions for you. There is always one you need!
- A. ABC
猜你喜欢
Johnson–Lindenstrauss Lemma
From the 18th line to the first line, the new story of the network security industry
Crawler practice website image batch download
96% of the collected traffic is prevented by bubble mart of cloud hosting
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Pagoda SSL can't be accessed? 443 port occupied? resolvent
WordPress collection WordPress hang up collection plug-in
The reasons why QT fails to connect to the database and common solutions
How to subcontract uniapp and applet, detailed steps (illustration) # yyds dry goods inventory #
3D game modeling is in full swing. Are you still confused about the future?
随机推荐
Lichuang EDA learning notes 14: PCB board canvas settings
Global and Chinese markets of advanced X-ray inspection system (Axi) in PCB 2022-2028: Research Report on technology, participants, trends, market size and share
Pagoda SSL can't be accessed? 443 port occupied? resolvent
Global and Chinese market of cell scrapers 2022-2028: Research Report on technology, participants, trends, market size and share
Valentine's Day - 9 jigsaw puzzles with deep love in wechat circle of friends
SQL statement
The "message withdrawal" of a push message push, one click traceless message withdrawal makes the operation no longer difficult
17. File i/o buffer
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
The difference between lambda expressions and anonymous inner classes
The "two-way link" of pushing messages helps app quickly realize two-way communication capability
[Yugong series] February 2022 attack and defense world advanced question misc-84 (MySQL)
13. Time conversion function
Global and Chinese market of digital impression system 2022-2028: Research Report on technology, participants, trends, market size and share
[untitled] the relationship between the metauniverse and digital collections
Introduction to graphics: graphic painting (I)
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.
Neo4j learning notes
LV1 previous life archives
What are the main investment products of bond funds and what are they