北大大牛代码 1240道题的原代码 超级权威

源代码在线查看: 3541615_ac_438ms_4968k.java

软件大小: 2414 K
上传用户: ATT320
关键词: 1240 代码 超级
下载地址: 免注册下载 普通下载 VIP

相关代码

				import java.util.*;
				import java.io.*;
				
				public class Main {
					private Scanner in = new Scanner(System.in);
				
					public static void main(String [] args) {
						new Main().run();
					}
				
					private void run() {
						while (in.hasNext()) {
							int n = in.nextInt();
							int id = in.nextInt();
							int num = in.nextInt();
							int [] p = new int [num];
							int [] t = new int [num];
							for (int i = 0; i < num; i++) {
								t[i] = p[i] = in.nextInt();
							}
							Arrays.sort(p);
							int r = num % n;
							int d = num / n;
							int pos;
							int min, max;
							if (id < r) {
								pos = id * (d + 1);
							} else {
								pos = r * (d + 1) + (id - r) * d;
							}
							min = p[pos];
							id++;
							if (id < r) {
								pos = id * (d + 1);
							} else {
								pos = r * (d + 1) + (id - r) * d;
							}
							pos--;
							max = p[pos];
							for (int i = 0; i < num; i++) {
								if (t[i] = min) {
									System.out.println(t[i]);
									break;
								}
							}
						}
					}
				}			

相关资源