pat:1080. Graduate Admission (30) part of the error (admission is school-oriented rather than the candidate's volunteer-led error)

Source: Internet
Author: User

#include<stdio.h>#include<string.h>#include<algorithm>Usingnamespace Std;int want[106];Number of students enrolled in each schoolstruct student{int ge,gi,sum,rank,id;int prefer[6];BOOL R;On behalf of the student's admission}stu[40066];BOOL CMP (Student a,student b) {if (a.sum!=b.sum)Return a.sum>b.sum;Elsereturn a.ge>b.ge;}int main () {memset (STU,0,sizeof (STU)); Fill (want,want+106,-1);Number of students in each school initial set-1int n,m,k;N candidates, M school, K volunteer scanf ("%d%d%d", &n,&m,&k);Forint i=0; I<m; ++i)Enter the number of schools enrolled scanf ("%d", &want[i]);Forint i=0; I<n; ++i) {scanf ("%d%d", &stu[i]. GE, &stu[i]. GI);Fill in the score stu[i].sum=stu[i]. Ge+stu[i]. HitFill in the total score stu[i].id=i;Fill in the numberForint j=0; j<k; ++J) {int tmp=-1; scanf"%d", &tmp);Fill in the volunteer stu[i].prefer[tmp]=1; }} sort (stu,stu+n,cmp); stu[0].rank=1;Forint i=1; I<n; ++i)Fill in Sort {if (stu[i].sum==stu[i-1].sum && Stu[i]. ge==stu[i-1]. GE) stu[i].rank=stu[i-1].rank;else stu[i].rank=i+1; }School priority option Law (not in accordance with test instructions)Forint i=0; I<m; ++i)Export admission information for each school {int top=0;Exception admission for output and rankingint kongge=0;Control the output of a spaceForint j=0; J<n; ++J) {if (Stu[j]. r==0 && stu[j].prefer[i]==1 && (want[i]>0 | | want[i]==0 && stu[j].rank==top)) //the student was not admitted, the student to apply for the school, the school is still hiring, or the school is full, only the students to tie this position {if (kongge!= 0) printf ( "  "%d", Stu[j]. ID); Kongge=1; top=stu[j].rank; //records the candidate's ranking Stu[j]. R=1; //mark candidates have dropped files--want[i]; //number of students required-1}} printf ( "\n");} return 0;}          

pat:1080. Graduate Admission (30) part of the error (admission is school-oriented rather than examinee-led error)

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.