結果

問題 No.31 悪のミックスジュース
ユーザー diginatudiginatu
提出日時 2014-09-29 01:14:12
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 2,746 ms
コンパイル使用メモリ 91,584 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 19:01:00
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 1 ms
4,368 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,368 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,368 KB
testcase_13 AC 1 ms
4,368 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv
	,std.array,std.algorithm, std.range
	,std.math;

void main(){
	auto buf = readln().strip().split().map!(to!int)();
  immutable int N = buf[0];
  immutable int V = buf[1];

	auto C = readln().strip().split().map!(to!int)();

  int now = 0;
  long ans = 0;

  long[100] cos;
  double[100] costd;

  cos[0] = C[0];

  foreach(immutable int i; 1 .. N)
    cos[i] = cos[i-1] + C[i];
  foreach(immutable int i; 0 .. N)
    costd[i] = cos[i].to!double / (i+1);

  ans += cos[N-1];

  if(N >= V) {
    writeln(ans);
    return;
  }

  int num = V - N;

  void tc(int n) {
    double minc = double.max;
    int mincp;
    foreach(immutable int i; 0 .. n) {
      if(minc > costd[i]) {
        minc = costd[i];
        mincp = i;
      }
    }

    ++ mincp;

    ans += (num / mincp) * cos[mincp-1];
    //writeln("~", mincp, "(", cos[mincp-1], ")", "*", num / mincp, "=>", ans);
    num %= mincp;
  }

  tc(N);
  while(num != 0) {
    tc(num);
  }

  writeln(ans);
}
0