当前位置:网站首页>repeat_ L2-009 red envelope grabbing_ sort
repeat_ L2-009 red envelope grabbing_ sort
2022-06-12 00:13:00 【This question AC sleep again】

// L2-009 Grab a red envelope
#include<bits/stdc++.h>
using namespace std;
// n<=1e4
const int N=2e4+5;
const int ID=1e4+5;
typedef struct people{ int id,cnt,sum; }P; P a[N];
bool cmp( P x,P y )
{
if( x.sum==y.sum )
{
return ( x.cnt==y.cnt ) ? ( x.id<y.id ) : ( x.cnt>y.cnt );
}
else return ( x.sum>y.sum ) ;
}
void init( int n )
{
for( int i=1;i<=n;i++ ) a[i].cnt=a[i].sum=0;
}
int main()
{
int n,k,i,id,cost;
for( i=1;i<ID;i++ ) a[i].id=i; // ID
while( ~scanf("%d",&n) )
{
init(n);
for( i=1;i<=n;i++ ) // Use... In the back n Not available here while
{
scanf("%d",&k); // The first i The line is numbered as i A record of people giving red envelopes // The topic should be studied clearly ! debug It takes too much time
while( k-- )
{
scanf("%d%d",&id,&cost);
a[i].sum-=cost;
a[id].cnt++;
a[id].sum+=cost;
}
}
sort( a+1,a+n+1,cmp );
for( i=1;i<=n;i++ ) printf("%d %.2lf\n",a[i].id, (double) a[i].sum / 100 );
}
return 0;
}
// ( In units ) ( In yuan , Output after decimal point 2 position ) Non negligible parentheses
边栏推荐
- [day 7 of JUC learning] reentrantlock and reentrantreadwritelock
- Procédures d'introduction et d'installation de sonarqube
- How to cancel smart table style in WPS table
- Oracle uses Navicat tool to import and export data
- Mingdeyang FPGA development board xilinx-k7 core board kinex7k325 410t industrial grade
- win10系统pscs6如何卸载
- (dp) acwing 899. Edit distance
- Creating and running JMeter performance test scenarios
- Two configurations of data tables in efcore
- Teach you to play with SSM framework
猜你喜欢
![将数组分成和相等的三个部分[问题分析]](/img/0b/856fcceb0373baa8acb46e9ae2c861.png)
将数组分成和相等的三个部分[问题分析]
![[JUC series] overview of executor framework](/img/e3/5131dcdd255c1571e64ae1f0459113.png)
[JUC series] overview of executor framework

SAP SD create / modify price list

Experiment 7 class construction and static member function

SF14 | supertrend "super trend" indicator magic change and upgrade (source code)

Introduction and installation steps of sonarqube

(dp) acwing 902. Minimum editing distance

Construction environnementale 2

Pre resolution and scope

How to package and send compressed files for mobile WPS
随机推荐
Mathematical modeling experience ----- summary of three modeling
How to send Apple phone WPS files to QQ mailbox
926. Flip String to Monotone Increasing
月份选择器禁用当月以后的数据 包含当月
Experiment four categories and objects
通过财报读懂企业的23个步骤
ironSource&nbsp; New functions are released, and developers can adjust advertising strategies in real time in the same session
How to achieve fair and equitable data access and service ecology?
Dom Knowledge point Summary
组态王如何利用无线Host-Link通信模块远程采集PLC数据?
chisel环境搭建(win10 + vscode)
自定义JSP标签->概念->生命周期
CD process
Redis master-slave replication, sentinel mode and cluster
Design principle [Demeter's Law]
How to uninstall pscs6 in win10 system
Design a MySQL table for message queue to store message data
Mmdetection custom fetch detection result script and image_ demo. Py parsing
Construction environnementale 2
"Failure" of the prospectus of Laowang: Laowang made its first dash for listing in Hong Kong, and the turnover rate continued to decline