1015

package com.company;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        int H = sc.nextInt();
        int[] id = new int[N];
        int[] de = new int[N];
        int[] cai = new int[N];
        for (int i = 0; i < N; i++) {
            id[i] = sc.nextInt();
            de[i] = sc.nextInt();//德分
            cai[i] = sc.nextInt();//才分
        }
        int number=0;

        //第一类排序
        int j = -1;
        int[][] stu1 = new int[N][3];
        int[][] sum1 = new int[N][2];
        for (int i = 0; i < N; i++) {
            if (de[i] >= H && cai[i] >= H) {//筛选学生
                number++;
                j++;
                stu1[j][0] = id[i];
                sum1[j][0]=id[i];
                stu1[j][1] = de[i];
                stu1[j][2] = cai[i];
                sum1[j][1]=de[i]+cai[i];
            }
        }
        Arrays.sort(stu1[j+1]);//总分从低到高的初步排序

        //对总分相同德分不同的情况进行排序
        //对总分相同德分相同的情况进行排序
        int temp1,temp2,temp3;
        for (int i=0;i<j+1;i++){
            for (int k=0;k<j+1;k++){
                if (sum1[i][1]==sum1[k][1]){//判断总分相同
                    if (stu1[i][1]==stu1[k][1]){//判断德分相同
                        if (stu1[i][0]>stu1[k][0]){//id不一样
                            if (i<k){
                                temp1=stu1[i][0];
                                temp2=stu1[i][1];
                                temp3=stu1[i][2];
                                stu1[i][0]=stu1[k][0];
                                stu1[i][1]=stu1[k][1];
                                stu1[i][2]=stu1[k][2];
                                stu1[k][0]=temp1;
                                stu1[k][1]=temp2;
                                stu1[k][2]=temp3;

                            }
                        }
                    }
                    if(stu1[i][1]>stu1[k][1]){
                        if (i<k){
                            temp1=stu1[i][0];
                            temp2=stu1[i][1];
                            temp3=stu1[i][2];
                            stu1[i][0]=stu1[k][0];
                            stu1[i][1]=stu1[k][1];
                            stu1[i][2]=stu1[k][2];
                            stu1[k][0]=temp1;
                            stu1[k][1]=temp2;
                            stu1[k][2]=temp3;
                        }
                    }
                    else{
                        if (i>k){
                            temp1=stu1[i][0];
                            temp2=stu1[i][1];
                            temp3=stu1[i][2];
                            stu1[i][0]=stu1[k][0];
                            stu1[i][1]=stu1[k][1];
                            stu1[i][2]=stu1[k][2];
                            stu1[k][0]=temp1;
                            stu1[k][1]=temp2;
                            stu1[k][2]=temp3;
                        }
                    }
                }
            }
        }

        int a=j+1;

        j = -1;
        int[][] stu2 = new int[N][3];
        int[][] sum2 = new int[N][2];
        for (int i = 0; i < N; i++) {
            if (de[i] >= H && cai[i] >= L&&cai[i]<H) {//筛选学生
                number++;
                j++;
                stu2[j][0] = id[i];
                sum2[j][0]=id[i];
                stu2[j][1] = de[i];
                stu2[j][2] = cai[i];
                sum2[j][1]=de[i]+cai[i];
            }
        }
        Arrays.sort(stu2[j+1]);//总分从低到高的初步排序

        //对总分相同德分不同的情况进行排序
        //对总分相同德分相同的情况进行排序
        for (int i=0;i<j+1;i++){
            for (int k=0;k<j+1;k++){
                if (sum2[i][1]==sum2[k][1]){//判断总分相同
                    if (stu2[i][1]==stu2[k][1]){//判断德分相同
                        if (stu2[i][0]>stu2[k][0]){//id不一样
                            if (i<k){
                                temp1=stu2[i][0];
                                temp2=stu2[i][1];
                                temp3=stu2[i][2];
                                stu2[i][0]=stu2[k][0];
                                stu2[i][1]=stu2[k][1];
                                stu2[i][2]=stu2[k][2];
                                stu2[k][0]=temp1;
                                stu2[k][1]=temp2;
                                stu2[k][2]=temp3;
                            }
                        }
                    }
                    if(stu2[i][1]>stu2[k][1]){
                        if (i<k){
                            temp1=stu2[i][0];
                            temp2=stu2[i][1];
                            temp3=stu2[i][2];
                            stu2[i][0]=stu2[k][0];
                            stu2[i][1]=stu2[k][1];
                            stu2[i][2]=stu2[k][2];
                            stu2[k][0]=temp1;
                            stu2[k][1]=temp2;
                            stu2[k][2]=temp3;
                        }
                    }
                    else{
                        if (i>k){
                            temp1=stu2[i][0];
                            temp2=stu2[i][1];
                            temp3=stu2[i][2];
                            stu2[i][0]=stu2[k][0];
                            stu2[i][1]=stu2[k][1];
                            stu2[i][2]=stu2[k][2];
                            stu2[k][0]=temp1;
                            stu2[k][1]=temp2;
                            stu2[k][2]=temp3;
                        }
                    }
                }
            }
        }

        int b=j+1;

        j = -1;
        int[][] stu3 = new int[N][3];
        int[][] sum3 = new int[N][2];
        for (int i = 0; i < N; i++) {
            if (de[i] < H && de[i] >=L&&cai[i] >= L&&cai[i]<H&&de[i]>=cai[i]) {//筛选学生
                number++;
                j++;
                stu3[j][0] = id[i];
                sum3[j][0]=id[i];
                stu3[j][1] = de[i];
                stu3[j][2] = cai[i];
                sum3[j][1]=de[i]+cai[i];
            }
        }
        Arrays.sort(stu3[j+1]);//总分从低到高的初步排序

        //对总分相同德分不同的情况进行排序
        //对总分相同德分相同的情况进行排序
        for (int i=0;i<j+1;i++){
            for (int k=0;k<j+1;k++){
                if (sum3[i][1]==sum3[k][1]){//判断总分相同
                    if (stu3[i][1]==stu3[k][1]){//判断德分相同
                        if (stu3[i][0]>stu3[k][0]){//id不一样
                            if (i<k){
                                temp1=stu3[i][0];
                                temp2=stu3[i][1];
                                temp3=stu3[i][2];
                                stu3[i][0]=stu3[k][0];
                                stu3[i][1]=stu3[k][1];
                                stu3[i][2]=stu3[k][2];
                                stu3[k][0]=temp1;
                                stu3[k][1]=temp2;
                                stu3[k][2]=temp3;
                            }
                        }
                    }
                    if(stu3[i][1]>stu3[k][1]){
                        if (i<k){
                            temp1=stu3[i][0];
                            temp2=stu3[i][1];
                            temp3=stu3[i][2];
                            stu3[i][0]=stu3[k][0];
                            stu3[i][1]=stu3[k][1];
                            stu3[i][2]=stu3[k][2];
                            stu3[k][0]=temp1;
                            stu3[k][1]=temp2;
                            stu3[k][2]=temp3;
                        }
                    }
                    else{
                        if (i>k){
                            temp1=stu3[i][0];
                            temp2=stu3[i][1];
                            temp3=stu3[i][2];
                            stu3[i][0]=stu3[k][0];
                            stu3[i][1]=stu3[k][1];
                            stu3[i][2]=stu3[k][2];
                            stu3[k][0]=temp1;
                            stu3[k][1]=temp2;
                            stu3[k][2]=temp3;
                        }
                    }
                }
            }
        }

        int c=j+1;

        j = -1;
        int[][] stu4 = new int[N][3];
        int[][] sum4 = new int[N][2];
        for (int i = 0; i < N; i++) {
            if (de[i] < H&& de[i] >=L&&de[i]<cai[i]) {//筛选学生
                number++;
                j++;
                stu4[j][0] = id[i];
                sum4[j][0]=id[i];
                stu4[j][1] = de[i];
                stu4[j][2] = cai[i];
                sum4[j][1]=de[i]+cai[i];
            }
        }
        Arrays.sort(stu4[j+1]);//总分从低到高的初步排序

        //对总分相同德分不同的情况进行排序
        //对总分相同德分相同的情况进行排序
        for (int i=0;i<j+1;i++){
            for (int k=0;k<j+1;k++){
                if (sum4[i][1]==sum4[k][1]){//判断总分相同
                    if (stu4[i][1]==stu4[k][1]){//判断德分相同
                        if (stu4[i][0]>stu4[k][0]){//id不一样
                            if (i<k){
                                temp1=stu4[i][0];
                                temp2=stu4[i][1];
                                temp3=stu4[i][2];
                                stu4[i][0]=stu4[k][0];
                                stu4[i][1]=stu4[k][1];
                                stu4[i][2]=stu4[k][2];
                                stu4[k][0]=temp1;
                                stu4[k][1]=temp2;
                                stu4[k][2]=temp3;
                            }
                        }
                    }
                    if(stu4[i][1]>stu4[k][1]){
                        if (i<k){
                            temp1=stu4[i][0];
                            temp2=stu4[i][1];
                            temp3=stu4[i][2];
                            stu4[i][0]=stu4[k][0];
                            stu4[i][1]=stu4[k][1];
                            stu4[i][2]=stu4[k][2];
                            stu4[k][0]=temp1;
                            stu4[k][1]=temp2;
                            stu4[k][2]=temp3;
                        }
                    }
                    else{
                        if (i>k){
                            temp1=stu4[i][0];
                            temp2=stu4[i][1];
                            temp3=stu4[i][2];
                            stu4[i][0]=stu4[k][0];
                            stu4[i][1]=stu4[k][1];
                            stu4[i][2]=stu4[k][2];
                            stu4[k][0]=temp1;
                            stu4[k][1]=temp2;
                            stu4[k][2]=temp3;
                        }
                    }
                }
            }
        }

        int d=j+1;

        System.out.println(number);
        for (int i=a-1;i>=0;i--){
            System.out.println(stu1[i][0]+" "+stu1[i][1]+" "+stu1[i][2]);
        }
        for (int i=b-1;i>=0;i--){
            System.out.println(stu2[i][0]+" "+stu2[i][1]+" "+stu2[i][2]);
        }
        for (int i=c-1;i>=0;i--){
            System.out.println(stu3[i][0]+" "+stu3[i][1]+" "+stu3[i][2]);
        }
        for (int i=d-1;i>=0;i--){
            System.out.println(stu4[i][0]+" "+stu4[i][1]+" "+stu4[i][2]);
        }
    }
}

 

posted @ 2018-10-02 11:02  博客园机器人  阅读(536)  评论(0)    收藏  举报