結果

問題 No.2482 Sandglasses
ユーザー kotatsugamekotatsugame
提出日時 2023-09-22 22:01:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 782 bytes
コンパイル時間 916 ms
コンパイル使用メモリ 80,188 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-28 09:01:27
合計ジャッジ時間 6,471 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 85 ms
6,528 KB
testcase_04 AC 88 ms
6,528 KB
testcase_05 AC 86 ms
6,528 KB
testcase_06 AC 85 ms
6,528 KB
testcase_07 AC 85 ms
6,528 KB
testcase_08 AC 86 ms
6,528 KB
testcase_09 AC 87 ms
6,528 KB
testcase_10 AC 85 ms
6,528 KB
testcase_11 AC 85 ms
6,528 KB
testcase_12 AC 84 ms
6,528 KB
testcase_13 AC 85 ms
6,528 KB
testcase_14 AC 85 ms
6,528 KB
testcase_15 AC 85 ms
6,528 KB
testcase_16 AC 87 ms
6,528 KB
testcase_17 AC 86 ms
6,528 KB
testcase_18 AC 87 ms
6,528 KB
testcase_19 AC 85 ms
6,528 KB
testcase_20 AC 87 ms
6,400 KB
testcase_21 AC 87 ms
6,528 KB
testcase_22 AC 88 ms
6,528 KB
testcase_23 AC 85 ms
6,528 KB
testcase_24 AC 85 ms
6,528 KB
testcase_25 AC 86 ms
6,400 KB
testcase_26 AC 84 ms
6,528 KB
testcase_27 AC 84 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<cassert>
using namespace std;
int N,K,T;
char C[2<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>K>>T;
	T%=2*K;
	for(int i=0;i<N;i++)cin>>C[i];
	vector<pair<int,int> >Ai(N);
	vector<int>B(N);
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		Ai[i].first=a;
		Ai[i].second=i;
		if(C[i]=='B')
		{
			int t=T;
			if(K-a>=t)a+=t;
			else
			{
				t-=K-a;
				if(K>=t)a=K-t;
				else a=t-K;
			}
		}
		else
		{
			int t=T;
			if(a>=t)a-=t;
			else
			{
				t-=a;
				if(K>=t)a=t;
				else a=K-(t-K);
			}
		}
		B[i]=a;
	}
	sort(B.begin(),B.end());
	vector<int>ans(N);
	sort(Ai.begin(),Ai.end());
	for(int i=0;i<N;i++)ans[Ai[i].second]=B[i];
	for(int i=0;i<N;i++)cout<<ans[i]<<" ";
	cout<<endl;
}
0