diff --git a/AtCoder/abc329/abc329_d/47798501.cpp b/AtCoder/abc329/abc329_d/47798501.cpp new file mode 100755 index 00000000..a8305666 --- /dev/null +++ b/AtCoder/abc329/abc329_d/47798501.cpp @@ -0,0 +1,29 @@ +// detail: https://atcoder.jp/contests/abc329/submissions/47798501 +#include +using namespace std; + +int main() { + int n, m; + cin >> n >> m; + + vector a(m); + for (auto &v : a) { + cin >> v; + v--; + } + + vector cnt(n + 1, 0); + int ans = 0; + + for (auto v : a) { + cnt[v]++; + + if (cnt[ans] < cnt[v]) { + ans = v; + } else if (cnt[ans] == cnt[v]) { + ans = min(ans, v); + } + + cout << ans + 1 << "\n"; + } +}