⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3473913_ac_2922ms_5224k.java

📁 北大大牛代码 1240道题的原代码 超级权威
💻 JAVA
字号:
import java.util.*;

class Info implements Comparable <Info> {
	
	int c, p, t, r;

	public Info(int c, int p, int t, int r) {
		this.c = c;this.t = t;
		this.p = p;this.r = r;
	}
	public int compareTo(Info that) {
		return this.t - that.t;
	}
};

class Foo implements Comparable <Foo> {
	int t, c;
	int [] p = new int [21];

	public int compareTo(Foo that) {
		if (this.p[0] != that.p[0]) {
			return that.p[0] - this.p[0];
		}
		if (this.t != that.t) {
			return this.t - that.t;
		}
		return this.c - that.c;
	}

	public Foo(int i) {
		this.t = 0;
		this.c = i;
		Arrays.fill(this.p, 0);
	}
}

public class Main {
	private Scanner in;

	public static void main(String [] args) {
		new Main().run();
	}

	private void run() {
		in = new Scanner (System.in);
		int c, n;

		c = in.nextInt();
		n = in.nextInt();
		Foo [] foo = new Foo [c + 1];
		Info [] info = new Info [n];
		for (int i = 0; i < n; i++) {
			info[i] = new Info(in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt());
		}
		for (int i = 1; i <= c; i++) {
			foo[i] = new Foo(i);
		}
		Arrays.sort(info);
		for (int i = 0; i < n; i++) {
			if (foo[info[i].c].p[info[i].p] == 1) {
				continue;
			}
			if (info[i].r != 0) {
				foo[info[i].c].t += info[i].t;
				foo[info[i].c].p[info[i].p] = 1;
				foo[info[i].c].p[0]++;
			} else {
				foo[info[i].c].t += 1200;
				foo[info[i].c].p[info[i].p]--;
			}
		}
		for (int i = 1; i <= c; i++) {
			for (int j = 1; j <= 20; j++) {
				if (foo[i].p[j] < 0) {
					foo[i].t -= foo[i].p[j] * (-1200);
					foo[i].p[j] = 0;
				}
			}
		}
		Arrays.sort(foo, 1, c + 1);
		for (int i = 1; i <= c; i++) {
			System.out.print(foo[i].c + " ");
		}
		System.out.println();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -