結果
問題 | No.2482 Sandglasses |
ユーザー |
|
提出日時 | 2023-09-23 00:32:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 161 ms / 2,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 1,982 ms |
コンパイル使用メモリ | 200,868 KB |
最終ジャッジ日時 | 2025-02-17 01:13:05 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main () { using ll = long long; int N; ll K, T; cin >> N >> K >> T; char A[200020]; pair<ll, int> B[200020]; for (int i = 0; i < N; i ++) { cin >> A[i]; } for (int j = 0; j < N; j ++) { ll b; cin >> b; B[j] = make_pair(b, j); } sort(B, B + N); ll ans[200020]; T %= (K * 2); for (int i = 0; i < N; i ++) { auto [b, j] = B[i]; char c = A[j]; if (c == 'A') { ll x = abs(T - b); if (x > K) { x = K - (x - K); } ans[i] = x; } else { ll y = K - b; y = abs(T - y); if (y > K) { y = K - (y - K); } ans[i] = K - y; } } sort(ans, ans + N); ll a2[200020]; for (int i = 0; i < N; i ++) { a2[B[i].second] = ans[i]; } for (int i = 0; i < N; i ++) { cout << a2[i] << " "; } cout << endl; }