l2-009. The order of the structure of red envelopes

Source: Internet
Author: User

l2-009. Time limit for red envelopes the memory limit of 65536 KB code length limit 8000 B procedure StandardAuthor Chen

No one has ever robbed a red envelope ... Here give the n person to each other to send red envelopes, Rob red envelopes record, please statistics they rob red envelopes harvest.

Input format:

Enter the first line to give a positive integer n (<= 104), that is, the total number of people involved in sending red envelopes and stealing red envelopes, the numbers are numbered from 1 to N. Then n lines, line I gives the person who is numbered I a red envelope record, the format is as follows:

K N1 P1 ... NK PK

where K (0 <= K <= 20) is issued to the number of red envelopes, NI is the number of people who grab the red envelopes, Pi (> 0) is the amount of the red packets they rob (to be divided into units). Note: For the same person issued red envelopes, each person can only grab 1 times, can not repeat rob.

Output format:

Output each person's number and revenue amount (in units of 2 digits after the decimal point) in descending order of income amount from high to low. Each person's information is on one line, with 1 spaces between the two numbers. If the amount of income has a side-by-side, press the number of packets to decrease the output; if there is a tie, increment the output by personal number.

Input Sample:
103 2 22 10 58 8 1255 1 345 3 211 5 233 7 13 8 1011 7 88002 1 1000 2 10002 4 250 10 3206 5 11 9 22 8 33 7 44 10 55 4 21 3 88002 1 23 2 1231 8 2504 2 121 4 516 7 112 9 10
Sample output:
1 11.632 3.638 3.633 2.117 1.696-1.679-2.1810-3.265-3.264-12.32


1#include <iostream>2#include <stdio.h>3#include <string>4#include <cstring>5#include <algorithm>6#include <Set>7#include <vector>8 9 using namespacestd;Ten  One structnode A { -     intId,co; -     DoubleMon; the}p[10005]; -  - BOOLCMP (node A,node b) - { +     if(A.mon==b.mon && a.co==b.co) -         returna.id<b.id; +     if(a.mon==B.mon) A         returnA.co>b.co; at     returnA.mon>B.mon; - } - intMain () - { -     intN,id=0, K; -Cin>>N; in      for(inti =1; I <= N; i++) -P[i].id=i; to     DoubleMo =0.0; +      for(inti =1; I <= N; i++) -     { theCin>>K; *          for(intj =1; J <= K; J + +) $         {Panax NotoginsengCin>>id>>mo; -p[id].co++,p[id].mon+=mo; thep[i].mon-=mo; +         } A     } theSort (p+1, p+1+n,cmp); +      for(inti =1; I <= N; i++) -printf"%d%.2lf\n", p[i].id,p[i].mon/100.00); $     return 0; $}

l2-009. The order of the structure of red envelopes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.