結果

問題 No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
ユーザー ks2mks2m
提出日時 2022-10-15 00:11:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 3,838 bytes
コンパイル時間 2,672 ms
実行使用メモリ 45,640 KB
スコア 928,517,802,689,802
最終ジャッジ日時 2022-10-15 00:12:00
合計ジャッジ時間 15,398 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
43,412 KB
testcase_01 AC 80 ms
43,496 KB
testcase_02 AC 79 ms
43,496 KB
testcase_03 AC 84 ms
43,600 KB
testcase_04 AC 80 ms
45,504 KB
testcase_05 AC 81 ms
43,580 KB
testcase_06 AC 80 ms
45,600 KB
testcase_07 AC 79 ms
45,384 KB
testcase_08 AC 80 ms
44,964 KB
testcase_09 AC 87 ms
44,872 KB
testcase_10 AC 83 ms
43,504 KB
testcase_11 AC 81 ms
45,492 KB
testcase_12 AC 79 ms
45,480 KB
testcase_13 AC 78 ms
43,304 KB
testcase_14 AC 79 ms
43,628 KB
testcase_15 AC 79 ms
43,360 KB
testcase_16 AC 83 ms
45,304 KB
testcase_17 AC 81 ms
45,332 KB
testcase_18 AC 80 ms
45,556 KB
testcase_19 AC 81 ms
43,584 KB
testcase_20 AC 77 ms
43,408 KB
testcase_21 AC 79 ms
45,412 KB
testcase_22 AC 79 ms
45,528 KB
testcase_23 AC 84 ms
43,360 KB
testcase_24 AC 82 ms
43,364 KB
testcase_25 AC 77 ms
43,364 KB
testcase_26 AC 81 ms
43,464 KB
testcase_27 AC 79 ms
45,516 KB
testcase_28 AC 89 ms
45,164 KB
testcase_29 AC 80 ms
45,536 KB
testcase_30 AC 80 ms
43,464 KB
testcase_31 AC 80 ms
45,452 KB
testcase_32 AC 80 ms
43,432 KB
testcase_33 AC 80 ms
43,564 KB
testcase_34 AC 88 ms
44,972 KB
testcase_35 AC 80 ms
45,520 KB
testcase_36 AC 85 ms
44,892 KB
testcase_37 AC 80 ms
43,508 KB
testcase_38 AC 87 ms
45,052 KB
testcase_39 AC 80 ms
45,640 KB
testcase_40 AC 84 ms
43,412 KB
testcase_41 AC 80 ms
45,472 KB
testcase_42 AC 80 ms
44,944 KB
testcase_43 AC 79 ms
43,528 KB
testcase_44 AC 87 ms
45,476 KB
testcase_45 AC 79 ms
45,396 KB
testcase_46 AC 83 ms
45,428 KB
testcase_47 AC 80 ms
45,552 KB
testcase_48 AC 80 ms
45,432 KB
testcase_49 AC 85 ms
45,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	static boolean debug = false;
	static boolean batch = false;
	static boolean readFile = false;
	static int num = 0;

	static int N, K;
	static int[] t, u;
	static double D;

	public static void main(String[] args) throws Exception {
		if (batch) {
			readFile = true;
		}
		if (readFile) {
			if (batch) {
				long tl = 2000; // TODO
				long tw = (long) (tl * 0.9);
				long total = 0;
				int bidx = 0;
				long best = 0;
				int widx = 0;
				long worst = 1000000000000000000L;
				int re = 0;
				int tle = 0;
				for (int z = 0; z < 100; z++) {
					try {
						makeCase();
						long st = System.currentTimeMillis();
						long score = solve();
						long time = System.currentTimeMillis() - st;
						if (time > tw) {
							System.out.println(z + ":\t" + score + "\t" + time + "ms");
							if (time > tl) {
								tle++;
							}
						} else {
							System.out.println(z + ":\t" + score);
						}
						total += score;
						if (score > best) {
							best = score;
							bidx = z;
						}
						if (score < worst) {
							worst = score;
							widx = z;
						}
					} catch (Exception e) {
						System.out.println(z + ":\t" + e.getMessage());
						re++;
					}
				}
				System.out.println("total: " + total);
				System.out.println("best: " + bidx + ": " + best);
				System.out.println("worst: " + widx + ": " + worst);
				System.out.println("RE: " + re);
				System.out.println("TLE: " + tle);
			} else {
				makeCase();
				long score = solve();
				System.out.println(score);
			}

		} else {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			init(br);
			solve();
		}
	}

	static void makeCase() {
		
	}

	static void init(BufferedReader br) throws Exception {
		String[] sa = br.readLine().split(" ");
		N = Integer.parseInt(sa[0]);
		K = Integer.parseInt(sa[1]);

		sa = br.readLine().split(" ");
		t = new int[K];
		for (int i = 0; i < K; i++) {
			t[i] = Integer.parseInt(sa[i]);
		}

		sa = br.readLine().split(" ");
		u = new int[K];
		for (int i = 0; i < K; i++) {
			u[i] = Integer.parseInt(sa[i]);
		}

		D = 20000000.0 / N / (N - 1);
	}

	static long solve() throws Exception {
		int[] b = new int[N];
		int[] m = new int[N];
		int[] e = new int[N];
		for (int i = 0; i < N; i++) {
			m[i] = 4;
			b[i] = rand(m[i], m[i] + 4);
			e[i] = rand(1, 3);
		}

		for (int i = 0; i < N; i++) {
			System.out.println(b[i] + " " + m[i] + " " + e[i]);
		}
		if (debug) {
			long score = score(b, m, e);
			System.out.println(score);
			return score;
		}
		return 0;
	}

	static long score(int[] b, int[] m, int[] e) {
		long sumt = 0;
		long sumu = 0;
		for (int i = 0; i < K; i++) {
			int[] x = new int[N];
			for (int j = 0; j < N; j++) {
				x[j] = getX(b[j], m[j], e[j], t[i]);
			}

			int max = 0;
			double val = 0;
			for (int j = 0; j < N - 1; j++) {
				for (int j2 = j + 1; j2 < N; j2++) {
					val += (double) Math.abs(x[j] - x[j2]) / (b[j] + b[j2]);
					max = Math.max(max, Math.abs(x[j] - x[j2]));
				}
			}
			sumt += Math.round(val * D);
			double v1 = max / 20.0 + 1;
			double v2 = Math.sqrt(v1);
			sumu += Math.round(10000000 / v2);
		}
		long avet = Math.round((double) sumt / K);
		long aveu = Math.round((double) sumu / K);
		if (debug) {
			System.out.println(avet);
			System.out.println(aveu);
		}
		return avet * aveu;
	}

	static int getX(int b, int m, int e, int time) {
		if (time <= b) {
			return time;
		}
		int nx = b;
		int nt = b;
		int h = Math.max(b * 2 - e, m * 2);
		int d = -1;
		while (true) {
			if (time <= nt + h) {
				return nx + (time - nt) * d;
			}
			nx += h * d;
			nt += h;
			h = Math.max(h - e * 2, m * 2);
			d = -d;
		}
	}

	static int rand(int l, int r) {
		int d = r - l;
		int ret = (int) (Math.random() * d);
		return ret + l;
	}
}
0