結果

問題 No.2482 Sandglasses
ユーザー ochiaigawaochiaigawa
提出日時 2023-09-22 22:44:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,291 bytes
コンパイル時間 2,679 ms
コンパイル使用メモリ 212,668 KB
実行使用メモリ 7,480 KB
最終ジャッジ日時 2024-04-28 09:03:03
合計ジャッジ時間 8,095 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 87 ms
7,480 KB
testcase_04 AC 85 ms
7,480 KB
testcase_05 AC 83 ms
7,480 KB
testcase_06 AC 84 ms
7,352 KB
testcase_07 AC 84 ms
7,480 KB
testcase_08 AC 83 ms
7,348 KB
testcase_09 AC 84 ms
7,480 KB
testcase_10 AC 84 ms
7,476 KB
testcase_11 AC 83 ms
7,352 KB
testcase_12 AC 84 ms
7,352 KB
testcase_13 AC 83 ms
7,352 KB
testcase_14 AC 84 ms
7,480 KB
testcase_15 AC 83 ms
7,480 KB
testcase_16 AC 84 ms
7,480 KB
testcase_17 AC 85 ms
7,480 KB
testcase_18 AC 84 ms
7,480 KB
testcase_19 AC 86 ms
7,480 KB
testcase_20 AC 84 ms
7,480 KB
testcase_21 AC 84 ms
7,456 KB
testcase_22 AC 84 ms
7,480 KB
testcase_23 AC 82 ms
7,480 KB
testcase_24 AC 83 ms
7,480 KB
testcase_25 AC 84 ms
7,352 KB
testcase_26 AC 82 ms
7,480 KB
testcase_27 AC 82 ms
7,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N, K, T;
  cin >> N >> K >> T;
  vector<char> a(N);
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<int> b(N);
  for(int i = 0; i < N; i++) {
    cin >> b[i];
  }
  // 2K 秒目にリセットされる
  // A の初期値が隣同士のものだけが作用する
  T %= (2 * K);
  vector<int> v;
  for(int i = 0; i < N; i++) {
    bool mode = (a[i] == 'A');
    int now = b[i];
    int S = 0;
    while(S < T) {
      if(mode) {
        if(now + S <= T) {
          S += now;
          now = 0;
          mode = false;
        } else {
          v.emplace_back(now + S - T);
          S = T;
        }
      } else {
        if((K - now) + S <= T) {
          S += (K - now);
          now = K;
          mode = true;
        } else {
          v.emplace_back(now + T - S);
          S = T;
        }
      }
    }
  }
  sort(v.begin(), v.end());
  vector<pair<int, int>> pr(N);
  for(int i = 0; i < N; i++) {
    pr[i] = make_pair(b[i], i);
  }
  sort(pr.begin(), pr.end());
  vector<int> ans(N);
  for(int i = 0; i < N; i++) {
    ans[pr[i].second] = v[i];
  }
  for(int i = 0; i < N; i++) {
    cout << ans[i] << " \n"[i == N - 1];
  }
  return 0;
}
0