diff --git a/01xxx/01813.cpp b/01xxx/01813.cpp new file mode 100644 index 00000000..fc956861 --- /dev/null +++ b/01xxx/01813.cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; + +int solve(void) { + int n; cin >> n; + + vector ans(n+1, 0); + for (int i=0; i> 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; +} \ No newline at end of file