結果
| 問題 |
No.2042 RGB Caps
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-09 00:51:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,008 bytes |
| コンパイル時間 | 1,016 ms |
| コンパイル使用メモリ | 119,268 KB |
| 最終ジャッジ日時 | 2025-02-12 21:04:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 13 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
int main(){
int N, K, now=0, M, A, R=0, G=0, B=0, x;
char c;
cin >> N >> K;
vector<pair<int, char>> ac(K);
for (int i=0; i<K; i++){
cin >> A >> c; A--;
ac[i] = {A, c};
}
sort(ac.begin(), ac.end());
vector<char> ans(N, '.');
queue<int> que;
for (int i=0; i<K; i++){
tie(A, c) = ac[i];
while(now <= A){
que.push(now);
now++;
}
if (c == 'R'){
M = max({G-R, B-R, (A-G-B-2*R+max(G, B)+2)/2});
if (M < 0) M = 0;
if (M > que.size()){
cout << -1 << endl;
return 0;
}
R += M;
for (int j=0; j<M; j++){
x = que.front();
ans[x] = 'R';
que.pop();
}
}
if (c == 'G'){
M = max({R-G, B-G, (A-R-B-2*G+max(R, B)+2)/2});
if (M < 0) M = 0;
if (M > que.size()){
cout << -1 << endl;
return 0;
}
G += M;
for (int j=0; j<M; j++){
x = que.front();
ans[x] = 'G';
que.pop();
}
}
if (c == 'B'){
M = max({G-B, R-B, (A-G-R-2*B+max(G, R)+2)/2});
if (M < 0) M = 0;
if (M > que.size()){
cout << -1 << endl;
return 0;
}
B += M;
for (int j=0; j<M; j++){
x = que.front();
ans[x] = 'B';
que.pop();
}
}
}
for (int i=0; i<N; i++){
cout << (ans[i] == '.' ? ac[K-1].second : ans[i]);
}
cout << endl;
return 0;
}
srjywrdnprkt