From a237f25d9a6625d3a2b7530d84d9f406b08c0afd Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 25 Jun 2022 20:12:13 +0800 Subject: [PATCH] B - 1D Pawn https://atcoder.jp/contests/abc257/submissions/32716853 --- AtCoder/ABC257/B/B.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 AtCoder/ABC257/B/B.cpp diff --git a/AtCoder/ABC257/B/B.cpp b/AtCoder/ABC257/B/B.cpp new file mode 100644 index 00000000..8cdb626f --- /dev/null +++ b/AtCoder/ABC257/B/B.cpp @@ -0,0 +1,43 @@ +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 205; + +int n, k, q, a[N]; +bool s[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> k >> q; + + for (int i = 1; i <= k; i++) { + cin >> a[i]; + + s[a[i]] = true; + } + + while (q--) { + int x; + + cin >> x; + + if (a[x] < n && !s[a[x] + 1]) { + s[a[x]] = false; + s[a[x] + 1] = true; + a[x]++; + } + } + + for (int i = 1; i <= k; i++) { + cout << a[i] << ' '; + } + + cout << endl; + + return 0; +}