Skip to content

Commit

Permalink
Add 01813.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiyabye committed Mar 26, 2024
1 parent 418b7eb commit afbe224
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions 01xxx/01813.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <vector>
using namespace std;

int solve(void) {
int n; cin >> n;

vector<int> ans(n+1, 0);
for (int i=0; i<n; i++) {
int x; cin >> x;
ans[x]++;
}

for (int i=n; i>=0; i--) {
if (ans[i] == i) return i;
}
return -1;
}

int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr);

cout << solve();
return 0;
}

0 comments on commit afbe224

Please sign in to comment.