結果

問題 No.1935 Water Simulation
ユーザー taisii2taisii2
提出日時 2022-05-13 21:45:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 863 bytes
コンパイル時間 1,556 ms
コンパイル使用メモリ 166,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 09:54:28
合計ジャッジ時間 2,831 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> V(4);
  long long N;
  for (int i = 0; i < 4; i++) {
    cin >> V[i];
  }
  cin >> N;
  vector<int> ans(4, 0);
  if (N < 4) {
    ans[0] = V[0];
    for (int i = 0; i < N; i++) {
      int w = min(ans[i], V[i + 1]);
      ans[i] -= w;
      ans[i + 1] += w;
    }
  } else {
    int idx = 0;
    int t = 100;
    for (int i = 0; i < 4; i++) {
      if (t >= V[i]) {
        idx = i;
        t = V[i];
      }
    }
    int v = V[0] - t;
    for (int i = idx; i >= 0; i--) {
      if (v - (V[i] - t) >= 0) {
        ans[i] += V[i] - t;
        v -= V[i] - t;
      } else {
        ans[i] += v;
        break;
      }
    }
    N %= 4;
    ans[N] += t;
  }
  for (int i = 0; i < 4; i++) {
    cout << ans[i];
    if (i == 3) {
      cout << endl;
    } else {
      cout << " ";
    }
  }
}
0