From afbe224a1280953a9224d183b2749975460ef795 Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Tue, 26 Mar 2024 23:17:41 +0900 Subject: [PATCH] Add 01813.cpp --- 01xxx/01813.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 01xxx/01813.cpp 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