pat:1055. The world ' s richest (+) AC

Source: Internet
Author: User

#include<stdio.h>#include<string.h>#include<algorithm>Usingnamespace Std;struct person{Char name[10];int Age,money;} p[100010];BOOL CMP (person A,person b) {if (A.money!=b.money)Return a.money>b.money;Elseif (a.age!=b.age)Return a.age<b.age;ElseReturn strcmp (A.name,b.name) <0;}int main () {int n,k; scanf"%d%d", &n,&k);Forint i=0; I<n; ++i) {scanf ("%s%d%d", &p[i].name, &p[i].age, &p[i].money);} Sort (p,p+n,cmp);Forint t=1; T<=k; ++T)Query k times {int cnt=0,qpeople,qyoung,qold;Output record CNT, output query maximum number of people, minimum age, maximum age scanf ("%d%d%d", &qpeople, &qyoung, &qold); printf "case #%d:\n" T "; for (int i=0; i<n; ++i) {if (cnt==qpeople) {//output is sufficient break;} if (P[i].age>=qyoung && p[i].age<=qold) {printf ( "%s%d%d\nif (0==cnt) {printf ( " none\nreturn 0;}          

pat:1055. The world ' s richest (+) AC

Related Article

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.