nyoj-carefully selected

Source: Internet
Author: User

This problem was supposed to be sorted by structure, and it was annoying to think.

Again to use a tag array, first mark the longest, and then the longest inside mark the most fine, and finally in the mark inside the output number of the largest

#include <iostream>#include<cstring>using namespacestd;Const intC =1010;intA[c];intB[c];intC[c];intSign[c];intMax =0;intMAXC =0;intMin =1000000000;intMain () {intN; CIN>>N; intm;  while(n--) {Max=0; MAXC=0; Min=1000000000; memset (sign,0,sizeof(sign)); CIN>>m;  for(inti =0; i < m; i + +) Cin>> A[i] >> B[i] >>C[i];  for(inti =0; I < m; i++)                if(A[i] >Max) Max=A[i];  for(inti =0; I < m; i++)                if(A[i] = =Max) Sign[i]=1;  for(inti =0; I < m; i++)                 if(Sign[i]&&b[i] <Min) Min=B[i];  for(inti =0; I < m; i++)                 if(sign[i]&& b[i]! =Min) Sign[i]=0;  for(inti =0; I < m; i++)                if(sign[i]&& C[i] >Maxc) MAXC=C[i]; cout<< MAXC <<Endl; }              return 0; }

The best code, people do not even open the array, saving a lot of code, concise and clear

#include<stdio.h>intMain () {intn,m,i,a,b,c,x,y,z; scanf ("%d",&N);  while(n--) {scanf ("%d",&m); A=0; b=0; c=0;  for(i=0; i<m;i++) {scanf ("%d%d%d",&x,&y,&z); if(x>a| | x==a&&y<b| | X==A&AMP;&AMP;Y==B&AMP;&AMP;Z&GT;C) {a=x;b=y;c=Z;} } printf ("%d\n", c); }    return 0;} 

Nyoj-carefully selected

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.