在 GESP四级的考试中,这题的代码长这样:
#include <bits/stdc++.h>
using namespace std;
long long n, a[1000005], day = 1;
int main () {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort (a + 1, a + n + 1);
for (int i = 1; i <= n; i++) {
if (a[i] >= day) day++;
}
cout << day - 1 << endl;
}
而这题困扰我很久之后长这样:
#include <bits/stdc++.h>
using namespace std;
int n, a[50005], b[50005], x = 1;
int main () {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) cin >> b[i];
sort (a + 1, a + n + 1);
sort (b + 1, b + n + 1);
for (int i = 1; i <= n; i++) {
if (a[i] >= b[x]) x++;
}
cout << x - 1 << endl;
}
简直就是一模一样的题!所以CCF是没有题目考了把原题变一下出来考的吗?