Skip to content

Commit

Permalink
add ../AtCoder/abc329/abc329_d/47798501.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
crawler committed Nov 21, 2023
1 parent cdb4030 commit a7ce506
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions AtCoder/abc329/abc329_d/47798501.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// detail: https://atcoder.jp/contests/abc329/submissions/47798501
#include <bits/stdc++.h>
using namespace std;

int main() {
int n, m;
cin >> n >> m;

vector<int> a(m);
for (auto &v : a) {
cin >> v;
v--;
}

vector<int> 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";
}
}

0 comments on commit a7ce506

Please sign in to comment.