結果
問題 | No.456 Millions of Submits! |
ユーザー | Grenache |
提出日時 | 2016-12-08 01:21:09 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 6,440 bytes |
コンパイル時間 | 4,978 ms |
コンパイル使用メモリ | 80,816 KB |
実行使用メモリ | 199,656 KB |
最終ジャッジ日時 | 2024-06-23 05:56:32 |
合計ジャッジ時間 | 15,733 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
57,128 KB |
testcase_01 | AC | 59 ms
50,376 KB |
testcase_02 | AC | 60 ms
50,488 KB |
testcase_03 | AC | 59 ms
50,472 KB |
testcase_04 | AC | 59 ms
50,500 KB |
testcase_05 | AC | 81 ms
51,292 KB |
testcase_06 | AC | 84 ms
51,296 KB |
testcase_07 | AC | 182 ms
56,364 KB |
testcase_08 | AC | 189 ms
56,824 KB |
testcase_09 | AC | 449 ms
61,544 KB |
testcase_10 | AC | 437 ms
60,988 KB |
testcase_11 | AC | 1,416 ms
76,744 KB |
testcase_12 | TLE | - |
ソースコード
import java.io.*; import java.util.*; import java.util.Map.*; public class Main_yukicoder456 { private static Scanner sc; private static Printer pr; private static void solve() { int m = sc.nextInt(); int[] a = new int[m]; int[] b = new int[m]; double[] t = new double[m]; // Map<Integer, List<Double>> hm = new HashMap<>(); Map<Integer, List<Integer>> hm2 = new HashMap<>(); for (int i = 0; i < m; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); t[i] = sc.nextDouble(); int tmp = a[i] * 100 + b[i]; if (!hm2.containsKey(tmp)) { // hm.put(tmp, new ArrayList<>()); hm2.put(tmp, new ArrayList<>()); } // hm.get(tmp).add(t[i]); hm2.get(tmp).add(i); } Map<Long, Double> ret = new HashMap<>(); // Queue<Double> l = new ArrayDeque<>(); // Queue<Double> r = new ArrayDeque<>(); // Queue<List<Integer>> ans = new ArrayDeque<>(); // Queue<Integer> cnt = new ArrayDeque<>(); Queue<Quad> q = new ArrayDeque<>(); for (Entry<Integer, List<Integer>> tt : hm2.entrySet()) { int aa = tt.getKey() / 100; int bb = tt.getKey() % 100; q.clear(); q.add(new Quad(0.0, 30000.0, tt.getValue(), 0)); // l.add(0.0); // r.add(30000.0); // ans.add(tt.getValue()); // cnt.add(0); while (!q.isEmpty()) { Quad ee = q.remove(); double ltmp = ee.l; double rtmp = ee.r; List<Integer> anstmp = ee.ans; int cnttmp = ee.cnt; if (cnttmp > 50) { for (int e : anstmp) { ret.put(e * 1_000_000_000L + tt.getKey(), rtmp); } continue; } List<Integer> ansr = new ArrayList<>(); List<Integer> ansl = new ArrayList<>(); // ansr.clear(); // ansl.clear(); double mid = (ltmp + rtmp) / 2; double f = Math.pow(mid, aa) * Math.pow(Math.log(mid), bb); for (int i = 0, size = anstmp.size(); i < size; i++) { // pr.printf("%e %e\n", mid, f); if (f >= t[anstmp.get(i)]) { ansr.add(anstmp.get(i)); } else { ansl.add(anstmp.get(i)); } } if (ansr.size() > 0) { q.add(new Quad(ltmp, mid, ansr, cnttmp + 1)); // l.add(ltmp); // r.add(mid); // ans.add(ansr); // cnt.add(cnttmp + 1); } if (ansl.size() > 0) { q.add(new Quad(mid, rtmp, ansl, cnttmp + 1)); // l.add(mid); // r.add(rtmp); // ans.add(ansl); // cnt.add(cnttmp + 1); } } } for (int i = 0; i < m; i++) { long key = i * 1_000_000_000L + a[i] * 100 + b[i]; // pr.printf("%.10f\n", ret.get(key)); pr.println(Double.toString(ret.get(key))); } } private static class Quad { double l; double r; List<Integer> ans; int cnt; Quad(double l, double r, List<Integer> ans, int cnt) { this.l = l; this.r = r; this.ans = ans; this.cnt = cnt; } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } private boolean isPrintable(int ch) { return ch >= '!' && ch <= '~'; } private boolean isCRLF(int ch) { return ch == '\n' || ch == '\r' || ch == -1; } private int nextPrintable() { try { int ch; while (!isPrintable(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } return ch; } catch (IOException e) { throw new NoSuchElementException(); } } String next() { try { int ch = nextPrintable(); StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (isPrintable(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } int nextInt() { try { // parseInt from Integer.parseInt() boolean negative = false; int res = 0; int limit = -Integer.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Integer.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } int multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } long nextLong() { try { // parseLong from Long.parseLong() boolean negative = false; long res = 0; long limit = -Long.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Long.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } long multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { try { int ch; while (isCRLF(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (!isCRLF(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new NoSuchElementException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }