結果

問題 No.1935 Water Simulation
ユーザー taisii2taisii2
提出日時 2022-05-13 21:44:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 166,168 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-29 06:48:22
合計ジャッジ時間 2,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> V(4);
  int 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] << " ";
  }
  cout << endl;
}
0