結果

問題 No.2482 Sandglasses
ユーザー tnakao0123tnakao0123
提出日時 2023-09-25 11:04:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 48,584 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2024-04-28 09:04:47
合計ジャッジ時間 6,056 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 92 ms
7,808 KB
testcase_04 AC 93 ms
7,680 KB
testcase_05 AC 93 ms
7,808 KB
testcase_06 AC 93 ms
7,808 KB
testcase_07 AC 92 ms
7,936 KB
testcase_08 AC 98 ms
7,808 KB
testcase_09 AC 91 ms
7,808 KB
testcase_10 AC 93 ms
7,808 KB
testcase_11 AC 96 ms
7,808 KB
testcase_12 AC 91 ms
7,808 KB
testcase_13 AC 92 ms
7,808 KB
testcase_14 AC 95 ms
7,808 KB
testcase_15 AC 93 ms
7,936 KB
testcase_16 AC 91 ms
7,808 KB
testcase_17 AC 93 ms
7,936 KB
testcase_18 AC 93 ms
7,808 KB
testcase_19 AC 92 ms
7,808 KB
testcase_20 AC 93 ms
7,808 KB
testcase_21 AC 92 ms
7,808 KB
testcase_22 AC 92 ms
7,680 KB
testcase_23 AC 92 ms
7,680 KB
testcase_24 AC 91 ms
7,808 KB
testcase_25 AC 94 ms
7,808 KB
testcase_26 AC 92 ms
7,808 KB
testcase_27 AC 93 ms
7,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2482.cc:  No.2482 Sandglasses - yukicoder
 */

#include<cstdio>
#include<algorithm>
#include<utility>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;
typedef pair<int,int> pii;

/* global variables */

int as[MAX_N], bs[MAX_N], cs[MAX_N], ds[MAX_N];
pii bis[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k, t;
  scanf("%d%d%d", &n, &k, &t);

  for (int i = 0; i < n; i++) {
    char s[4];
    scanf("%s", s);
    as[i] = s[0];
  }
  for (int i = 0; i < n; i++) scanf("%d", bs + i);

  int k2 = k * 2;
  t %= k2;

  for (int i = 0; i < n; i++) {
    bis[i] = pii(bs[i], i);
    int ti = (as[i] == 'B') ? ((ll)bs[i] + t) % k2 : ((ll)k2 - bs[i] + t) % k2;
    cs[i] = (ti < k) ? ti : k2 - ti;
  }
  sort(bis, bis + n);
  sort(cs, cs + n);

  for (int i = 0; i < n; i++) ds[bis[i].second] = cs[i];
  
  for (int i = 0; i < n; i++)
    printf("%d%c", ds[i], (i + 1 < n) ? ' ' : '\n');

  return 0;
}
0