当前位置:网站首页>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;
}边栏推荐
- Design and implementation of redis 7.0 multi part AOF
- 14. Process time
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- Learn these super practical Google browser skills, girls casually flirt
- Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog
- C # learning notes: structure of CS documents
- Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
- Gee import SHP data - crop image
- WordPress collection WordPress hang up collection plug-in
- Record a problem that soft deletion fails due to warehouse level error
猜你喜欢

Override and virtual of classes in C #

Zblog collection plug-in does not need authorization to stay away from the cracked version of zblog

Redis transaction

FRP intranet penetration

Database concept and installation

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.

High level application of SQL statements in MySQL database (I)

Introduction to graphics: graphic painting (I)

What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended

Yyds dry goods inventory hand-in-hand teach you the development of Tiktok series video batch Downloader
随机推荐
Containerization technology stack
Database concept and installation
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
A brief talk on professional modeler: the prospect and professional development of 3D game modeling industry in China
LV1 previous life archives
Yyds dry goods inventory override and virtual of classes in C
Question C: Huffman tree
求esp32C3板子連接mssql方法
Measurement fitting based on Halcon learning [4] measure_ arc. Hdev routine
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
C learning notes: C foundation - Language & characteristics interpretation
Chapter 3.4: starrocks data import - Flink connector and CDC second level data synchronization
Write the first CUDA program
Basic editing specifications and variables of shell script
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Libcblas appears when installing opencv import CV2 so. 3:cannot open shared object file:NO such file or directory
Leetcode 110 balanced binary tree
Sword finger offer 14- I. cut rope
PTA tiantisai l1-079 tiantisai's kindness (20 points) detailed explanation