結果

問題 No.1808 Fullgold Alchemist
ユーザー ππ
提出日時 2022-01-14 23:19:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 994 ms
コンパイル使用メモリ 77,728 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-12 22:16:11
合計ジャッジ時間 4,470 ms
ジャッジサーバーID
(参考情報)
judge8 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,384 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,384 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:40:13: 警告: ‘nmin’ may be used uninitialized [-Wmaybe-uninitialized]
   40 |   x += nmin / m;
      |        ~~~~~^~~
main.cpp:7:18: 備考: ‘nmin’ はここで定義されています
    7 |   int stock = 0, nmin;
      |                  ^~~~
main.cpp:40:5: 警告: ‘x’ may be used uninitialized [-Wmaybe-uninitialized]
   40 |   x += nmin / m;
      |   ~~^~~~~~~~~~~
main.cpp:6:7: 備考: ‘x’ はここで定義されています
    6 |   int x;
      |       ^

ソースコード

diff #

#include<iostream>

int main() {
  int n, m;
  std::cin >> n >> m;
  int x;
  int stock = 0, nmin;
  for(int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    int w = a / (m * (n - i));
    a %= m * (n - i);
    if(i == 0) {
      x = w;
      nmin = a;
    } else {
      if(w * m < nmin) {
        nmin -= w * m;
        x += w;
      } else if(w * m >= nmin) {
        x += nmin / m;
        goto end;
      }
      if(a < nmin) {
        while(nmin - a > stock) {
          if(nmin == 0) {
            goto end;
          } else {
            --nmin;
            stock += i;
          }
        }
        stock -= nmin - a;
        a += nmin - a;
      } else {
        stock += a - nmin;
      }
    }
  }
  x += nmin / m;
 end:
  std::cout << x << '\n';
}
0