From c1a76355ac2e344ccc55efdad1287c2d2b8535dc Mon Sep 17 00:00:00 2001 From: hao14293 Date: Mon, 3 Dec 2018 12:59:48 +0800 Subject: [PATCH] =?UTF-8?q?Create=201060.=E7=88=B1=E4=B8=81=E9=A1=BF?= =?UTF-8?q?=E6=95=B0=20=EF=BC=8825=20=E5=88=86=EF=BC=89.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PAT/PAT-B/CPP/1060.爱丁顿数 (25 分).cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 PAT/PAT-B/CPP/1060.爱丁顿数 (25 分).cpp diff --git a/PAT/PAT-B/CPP/1060.爱丁顿数 (25 分).cpp b/PAT/PAT-B/CPP/1060.爱丁顿数 (25 分).cpp new file mode 100644 index 0000000..36effac --- /dev/null +++ b/PAT/PAT-B/CPP/1060.爱丁顿数 (25 分).cpp @@ -0,0 +1,23 @@ +#include +#include +#include +using namespace std; +bool cmp(int a, int b){ + return a > b; +} +int main(){ + int n; + scanf("%d", &n); + vector v(n + 1); + for(int i = 1; i <= n; ++i){ + scanf("%d", &v[i]); + } + sort(v.begin() + 1, v.end(), cmp); + int e = 0, i = 1; + while(i <= n && v[i] > i){ + ++e; + ++i; + } + printf("%d\n", e); + return 0; +}