結果

問題 No.5018 Let's Make a Best-seller Book
ユーザー allegrogikenallegrogiken
提出日時 2023-10-01 20:04:31
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 31 ms / 400 ms
コード長 3,416 bytes
コンパイル時間 1,634 ms
コンパイル使用メモリ 165,320 KB
実行使用メモリ 24,492 KB
スコア 62,487
平均クエリ数 52.00
最終ジャッジ日時 2023-10-01 20:04:41
合計ジャッジ時間 10,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
23,376 KB
testcase_01 AC 28 ms
24,372 KB
testcase_02 AC 28 ms
23,424 KB
testcase_03 AC 28 ms
23,376 KB
testcase_04 AC 29 ms
24,360 KB
testcase_05 AC 29 ms
23,508 KB
testcase_06 AC 28 ms
24,048 KB
testcase_07 AC 28 ms
24,060 KB
testcase_08 AC 28 ms
24,048 KB
testcase_09 AC 29 ms
23,532 KB
testcase_10 AC 29 ms
23,640 KB
testcase_11 AC 28 ms
24,492 KB
testcase_12 AC 29 ms
24,372 KB
testcase_13 AC 28 ms
23,376 KB
testcase_14 AC 28 ms
23,376 KB
testcase_15 AC 28 ms
23,832 KB
testcase_16 AC 27 ms
24,228 KB
testcase_17 AC 28 ms
24,048 KB
testcase_18 AC 28 ms
23,400 KB
testcase_19 AC 27 ms
23,364 KB
testcase_20 AC 28 ms
23,592 KB
testcase_21 AC 28 ms
23,652 KB
testcase_22 AC 29 ms
24,048 KB
testcase_23 AC 28 ms
24,048 KB
testcase_24 AC 28 ms
23,424 KB
testcase_25 AC 29 ms
24,036 KB
testcase_26 AC 28 ms
24,024 KB
testcase_27 AC 28 ms
23,640 KB
testcase_28 AC 27 ms
23,664 KB
testcase_29 AC 28 ms
23,376 KB
testcase_30 AC 28 ms
23,544 KB
testcase_31 AC 28 ms
24,048 KB
testcase_32 AC 29 ms
24,264 KB
testcase_33 AC 28 ms
24,036 KB
testcase_34 AC 29 ms
23,412 KB
testcase_35 AC 28 ms
23,520 KB
testcase_36 AC 29 ms
23,676 KB
testcase_37 AC 29 ms
23,400 KB
testcase_38 AC 29 ms
24,372 KB
testcase_39 AC 28 ms
23,964 KB
testcase_40 AC 29 ms
23,376 KB
testcase_41 AC 29 ms
23,412 KB
testcase_42 AC 29 ms
23,844 KB
testcase_43 AC 29 ms
24,396 KB
testcase_44 AC 28 ms
24,264 KB
testcase_45 AC 27 ms
24,348 KB
testcase_46 AC 28 ms
24,036 KB
testcase_47 AC 28 ms
23,376 KB
testcase_48 AC 28 ms
24,048 KB
testcase_49 AC 28 ms
24,036 KB
testcase_50 AC 28 ms
23,520 KB
testcase_51 AC 29 ms
23,412 KB
testcase_52 AC 29 ms
24,396 KB
testcase_53 AC 28 ms
23,412 KB
testcase_54 AC 29 ms
24,048 KB
testcase_55 AC 28 ms
23,532 KB
testcase_56 AC 29 ms
23,664 KB
testcase_57 AC 28 ms
24,048 KB
testcase_58 AC 29 ms
24,276 KB
testcase_59 AC 28 ms
24,384 KB
testcase_60 AC 28 ms
23,844 KB
testcase_61 AC 27 ms
24,396 KB
testcase_62 AC 28 ms
24,048 KB
testcase_63 AC 28 ms
23,676 KB
testcase_64 AC 28 ms
23,652 KB
testcase_65 AC 28 ms
24,036 KB
testcase_66 AC 29 ms
24,036 KB
testcase_67 AC 29 ms
24,420 KB
testcase_68 AC 28 ms
23,412 KB
testcase_69 AC 28 ms
24,396 KB
testcase_70 AC 28 ms
23,376 KB
testcase_71 AC 29 ms
24,036 KB
testcase_72 AC 28 ms
23,628 KB
testcase_73 AC 29 ms
23,424 KB
testcase_74 AC 29 ms
23,832 KB
testcase_75 AC 29 ms
23,376 KB
testcase_76 AC 29 ms
23,652 KB
testcase_77 AC 28 ms
23,520 KB
testcase_78 AC 29 ms
23,376 KB
testcase_79 AC 28 ms
24,036 KB
testcase_80 AC 29 ms
24,060 KB
testcase_81 AC 29 ms
23,364 KB
testcase_82 AC 28 ms
24,360 KB
testcase_83 AC 29 ms
24,036 KB
testcase_84 AC 29 ms
23,640 KB
testcase_85 AC 29 ms
23,412 KB
testcase_86 AC 29 ms
23,652 KB
testcase_87 AC 29 ms
23,844 KB
testcase_88 AC 28 ms
24,396 KB
testcase_89 AC 28 ms
24,336 KB
testcase_90 AC 29 ms
24,396 KB
testcase_91 AC 29 ms
23,532 KB
testcase_92 AC 29 ms
24,048 KB
testcase_93 AC 28 ms
23,544 KB
testcase_94 AC 29 ms
24,048 KB
testcase_95 AC 28 ms
24,264 KB
testcase_96 AC 29 ms
23,664 KB
testcase_97 AC 29 ms
23,412 KB
testcase_98 AC 29 ms
24,036 KB
testcase_99 AC 29 ms
23,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main() { runSolver(); }

// ----------------------------------------------

void problem() {
  auto T = scan!int;
  auto N = scan!int;
  auto M = scan!long;
  auto rnd = Xorshift(unpredictableSeed);

  auto idealStock = 61.iota.map!(a => (pow(1.05f, 2*a) / 0.16f).to!long).array;

  auto solve() {
    int preStrategy;
    foreach(week; 0..T) {
      auto money = week == 0 ? M : scan!long;
      if (money == -1) return;

      auto sold = week == 0 ? new long[](N) : scan!long(N);
      auto popularities = week == 0 ? new long[](N) : scan!long(N);
      auto stocks = week == 0 ? new long[](N) : scan!long(N);

      auto orders = new long[](N);
      long bookCost;
      foreach(i; N.iota.array.sort!((a, b) => popularities[a] > popularities[b])) {
        auto lot = idealStock[max(0, popularities[i])] * (week > 47 ? 4 : 1);
        orders[i] = max(0, lot - stocks[i]);

        if (bookCost + orders[i]*500 > money) {
          orders[i] = (money - bookCost) / 500;
        }
        bookCost += orders[i] * 500;
      }

      if (week <= 47 && money >= M && popularities.maxElement <= 55) {
        foreach_reverse(level; 1..6) {
          long cost = 500_000L * 2L^^(level - 1);
          if (money - cost >= M / 2) {
            writefln("2 %d", level);
            break;
          }
        }
        preStrategy = 2;
      } else {
        writefln("1 %(%d %)", orders);
        preStrategy = 1;
      }
      stdout.flush();
    }
  }

  outputForAtCoder(&solve);
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, std.math, std.typecons, std.numeric, std.traits, std.functional, std.bigint, std.datetime.stopwatch, core.time, core.bitop, std.random;
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(long n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug { write("#"); writeln(t); }}
T[] divisors(T)(T n) { T[] ret; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { ret ~= i; if (i * i != n) ret ~= n / i; } } return ret.sort.array; }
bool chmin(T)(ref T a, T b) { if (b < a) { a = b; return true; } else return false; }
bool chmax(T)(ref T a, T b) { if (b > a) { a = b; return true; } else return false; }
string charSort(alias S = "a < b")(string s) { return (cast(char[])((cast(byte[])s).sort!S.array)).to!string; }
ulong comb(ulong a, ulong b) { if (b == 0) {return 1;}else{return comb(a - 1, b - 1) * a / b;}}
string toAnswerString(R)(R r) { return r.map!"a.to!string".joiner(" ").array.to!string; }
void outputForAtCoder(T)(T delegate() fn) {
  static if (is(T == float) || is(T == double) || is(T == real)) "%.16f".writefln(fn());
  else static if (is(T == void)) fn();
  else static if (is(T == string)) fn().writeln;
  else static if (isInputRange!T) {
    static if (!is(string == ElementType!T) && isInputRange!(ElementType!T)) foreach(r; fn()) r.toAnswerString.writeln;
    else foreach(r; fn()) r.writeln;
  }
  else fn().writeln;
}
void runSolver() {
  enum BORDER = "#==================================";
  debug { BORDER.writeln; while(true) { "#<<< Process time: %s >>>".writefln(benchmark!problem(1)); BORDER.writeln; } }
  else problem();
}
enum YESNO = [true: "Yes", false: "No"];

// -----------------------------------------------
0