求助!PAT甲级1012,我用Java这样写,最后一个测试例会超时!

PAT甲级的1012题,排序题,我用Java这样写的,思路跟C++代码思路类似,但是最后一个测试用例会超时,还请大佬们看一看怎么修改可以通过~~
感谢!感谢!感谢!

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

class Node {
	int id, best;
	int score[] = new int[4];
	int rank[] = new int[4];
}

class NodeComparator implements Comparator
{
	int flag = 0;
	public NodeComparator(int flag)
	{
		this.flag = flag;
	}
	public int compare(Node o1, Node o2) {
		return  o2.score[flag] - o1.score[flag];
	}
}

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] strs = line.split(" ");
		int n = Integer.parseInt(strs[0]);
		int m = Integer.parseInt(strs[1]);
		Node stu[] = new Node[n];
		for(int i=0; i0)
			{
				int best = stu[temp-1].best;
				System.out.println(stu[temp-1].rank[best] + " " + c[best]);
			}else {
				System.out.println("N/A");
			}
		}
	}
}

 

你可能感兴趣的:(求助!PAT甲级1012)