text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
long long int stringtoLLI(string str) {
long long int val;
stringstream ss;
ss << str;
ss >> val;
return val;
}
string LLItostring(long long int val) {
string str;
stringstream ss;
ss << val;
ss >> str;
return str;
}
long long int n, m, k, ar[100009], fst[100009], snd[100009], table[100009];
string str;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
;
while (cin >> n) {
for (int i = 0; i < n; i++) {
cin >> ar[i];
}
sort(ar, ar + n);
long long int val = ar[0];
if (val > 1) val = 1;
ar[0] = val;
for (int i = 1; i < n; i++) {
if (abs(ar[i] - val) > 1) ar[i] = val + 1;
val = ar[i];
}
long long int mx = INT_MIN;
for (int i = 0; i < n; i++) {
if (mx < ar[i]) mx = ar[i];
}
cout << mx + 1 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long n, i;
cin >> n;
long long ar[n], j;
for (i = 0; i < n; ++i) cin >> ar[i];
sort(ar, ar + n);
j = 1;
for (i = 0; i < n; ++i) {
if (ar[i] >= j) ++j;
}
cout << j << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int cnt = 1;
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
m[x]++;
}
for (auto i : m) {
while (i.second > 0 && i.first >= cnt) {
i.second--;
cnt++;
}
}
cout << cnt << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
vector<int> v;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
if (a[0] > 1) {
a[0] = 1;
v.push_back(1);
} else
v.push_back(1);
for (int i = 1; i < n; i++) {
if (a[i] - a[i - 1] > 1) {
v.push_back(a[i - 1] + 1);
a[i] = a[i - 1] + 1;
} else
v.push_back(a[i]);
}
cout << v[v.size() - 1] + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
int k = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= k) {
a[i] = k;
k++;
}
}
cout << k;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10, M = 510, INF = 0x3f3f3f3f, base = 131;
long long a[N], b[10];
signed main() {
ios::sync_with_stdio(false);
long long n;
cin >> n;
for (long long i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + 1 + n);
long long ans = 1;
for (long long i = 1; i <= n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[100000];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
int temp_answer = 1;
for (int i = 0; i < n; i++) {
if (arr[i] >= temp_answer) temp_answer++;
}
cout << temp_answer;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end());
int i = 1;
for (int idx = 0; idx < n; idx++) {
if (i <= v[idx]) i++;
}
cout << i << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
multiset<int> v;
multiset<int>::iterator it;
int main() {
int n;
scanf("%d", &n);
for (int(i) = 0; (i) < (n); (i)++) {
int x;
scanf("%d", &x);
v.insert(x);
}
bool flag = false;
int ans;
for (int(i) = (1); (i) <= (n); (i)++) {
it = v.lower_bound(i);
if (it != v.end())
v.erase(it);
else {
ans = i;
flag = true;
break;
}
}
if (flag)
cout << ans;
else
cout << n + 1;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long int n;
cin >> n;
long int a[n];
for (long int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
long int ans = 1;
for (long int i = 0; i < n; i++) {
if (a[i] >= ans) {
a[i] = ans;
ans++;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, ans = 1;
int main() {
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(((a).begin()), ((a).end()));
for (int i = 0; i < n; i++) {
if (a[i] >= ans) {
ans++;
}
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long a[n + 1];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
if (a[0] > 1) a[0] = 1;
for (long long i = 1; i < n; i++) {
if (a[i] >= a[i - 1] + 1) a[i] = a[i - 1] + 1;
}
cout << a[n - 1] + 1;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a, a + n);
int c = 1;
for (int i = 0; i < n; ++i)
if (a[i] >= c) {
a[i] = c;
c++;
}
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int a[maxn];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (int i = 1; i <= n; i++)
if (i == 1) {
if (a[i - 1] != 1) a[0] = 1;
} else if (a[i - 1] > a[i - 2] + 1)
a[i - 1] = a[i - 2] + 1;
cout << a[n - 1] + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
long long mo = 1000000007;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<long long> v;
for (int i = 0; i < n; i++) {
int t;
cin >> t;
v.push_back(t);
}
long long res = 1;
sort(v.begin(), v.end());
for (int i = 0; i < n; i++) {
if (v[i] >= res) {
res++;
}
}
cout << res;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int arr[100005];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
sort(arr, arr + n);
int ans = 1;
for (int i = 0; i < n; i++) {
if (arr[i] >= ans) {
ans++;
}
}
printf("%d\n", ans);
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1234567;
const int minn = -1234567;
const long long x = 1000000007;
int a[maxn];
vector<int> v1;
map<int, int> m1, m2;
set<int> s1;
vector<pair<int, int> > vp1;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
m1[a[i]]++;
}
sort(a, a + n);
int cnt = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= cnt) cnt++;
}
cout << cnt;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n + 1];
for (int i = int(0); i <= int(n - 1); i++) {
cin >> a[i];
}
if (n == 1) {
cout << 2 << endl;
return 0;
}
sort(a, a + n);
a[0] = 1;
for (int i = int(1); i <= int(n - 1); i++) {
if (a[i] != a[i - 1]) a[i] = a[i - 1] + 1;
}
cout << a[n - 1] + 1 << endl;
}
|
#include <bits/stdc++.h>
const int maxn = 100000;
using namespace std;
int n;
int a[maxn + 10];
int main() {
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
if (n == 1) {
printf("2\n");
continue;
}
sort(a, a + n);
a[0] = 1;
for (int i = 1; i < n; i++) {
if (a[i] != a[i - 1]) {
if (a[i] != a[i - 1] + 1) a[i] = a[i - 1] + 1;
}
}
printf("%d\n", a[n - 1] + 1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
priority_queue<int> q, r;
map<int, bool> p;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
q.push(-a);
}
int m = 1;
while (!q.empty()) {
int ans = -q.top();
q.pop();
if (!p[m] && m <= ans) p[m++];
}
cout << m << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[100005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
int j = 1;
for (int i = 0; i < n; i++) {
if (arr[i] >= j) {
j++;
}
}
cout << j << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int arr[100001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
sort(arr, arr + n);
int cur = 1;
for (int i = 0; i < n; i++) {
if (cur <= arr[i]) {
cur++;
}
}
cout << cur;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> elements;
int n;
long long a, answer = 1;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
elements.push_back(a);
}
sort(elements.begin(), elements.end());
for (int i = 0; i < elements.size(); i++) {
if (answer <= elements[i]) {
answer += 1;
}
}
cout << answer;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, m, k;
cin >> n;
long long a[n];
map<int, int> mp;
for (int i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]]++;
}
sort(a, a + n);
for (int i = 1; i <= 1000003; i++) {
if (mp.lower_bound(i) == mp.end()) {
cout << i << endl;
return 0;
} else {
auto itr = mp.lower_bound(i);
int k = (*itr).first;
if (mp[k] > 1)
mp[k]--;
else
mp.erase(k);
}
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
uint32_t n;
std::cin >> n;
std::vector<uint32_t> arr(n);
for (uint32_t i = 0; i < n; ++i) {
std::cin >> arr[i];
}
std::sort(arr.begin(), arr.end());
uint32_t ans(n + 1);
uint32_t curvalue(1);
for (uint32_t i = 1; i <= n; ++i) {
if (curvalue > arr[i - 1]) {
--ans;
} else {
++curvalue;
}
}
std::cout << ans << std::endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i, count = 1;
cin >> n;
long long int a[n + 69];
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
for (i = 0; i < n; i++)
if (count <= a[i]) count++;
cout << count << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
if (a == 0) return b;
return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
T ans = 1;
while (b > 0) {
if (b % 2 == 1) ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans % m;
}
int main() {
long long t, n, i, p, s, j, x, f = 0;
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cin >> n;
vector<long long> v;
for (i = 0; i < n; i++) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
long long cur = 1;
for (i = 0; i < n; i++) {
if (v[i] >= cur) {
cur++;
}
}
cout << cur;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100111];
int main() {
ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
int ans = 1;
for (int i = 1; i <= n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], c, mn = 1;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (a[i] >= mn) mn++;
}
printf("%d", mn);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int static dp[1005][1005];
const int MOD = 1e9 + 7;
bool check(int x) {
int y = sqrt(x);
return y * y == x;
}
void solve() {
int n;
cin >> n;
int a[n + 1];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int mex = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= mex) {
mex++;
}
}
cout << mex << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[int(1e5) + 10];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
int cur = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= cur) cur++;
}
cout << cur << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 150000 + 500;
int main() {
int n;
cin >> n;
int x;
vector<int> v;
for (int i = 0; i < n; ++i) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
int cur = 1;
for (int i = 0; i < n; ++i) {
if (v[i] >= cur) cur++;
}
puts("\n");
cout << cur << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, arr[100100];
while (scanf("%I64d", &n) == 1) {
for (int i = 0; i < n; i++) {
scanf("%I64d", &arr[i]);
}
sort(arr, arr + n);
int k = 1;
for (int i = 0; i < n; i++) {
if (arr[i] >= k) {
++k;
}
}
cout << k << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
void solve() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
arr[0] = 1;
for (int i = 0; i < n - 1; i++) {
if (arr[i] < arr[i + 1]) arr[i + 1] = arr[i] + 1;
}
cout << arr[n - 1] + 1 << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
|
#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
return *(const int *)a - *(const int *)b;
}
int a[100000];
int main(void) {
int i;
int n;
int p;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", a + i);
qsort(a, n, sizeof(int), &compare);
p = 1;
for (i = 0; i < n; i++) p += p <= a[i];
printf("%d\n", p);
return 0;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int &x) {
char c;
while ((c = getchar()) < '0' || c > '9')
;
x = c - '0';
while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
int a[100005];
int main() {
int n;
while (cin >> n) {
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
int ans = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= ans) {
a[i] = ans;
ans = a[i] + 1;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int a[n];
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
int x = 1;
for (int i = 0; i <= n - 1; i++) {
if (a[i] >= x) x++;
}
printf("%d", x);
printf("\n");
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];
int main() {
while (~scanf("%d", &n)) {
for (int i = 0; i < n; i++) {
scanf("%d", a + i);
}
sort(a, a + n);
a[0] = 1;
for (int i = 1; i < n; i++) {
a[i] = min(a[i - 1] + 1, a[i]);
}
printf("%d\n", a[n - 1] + 1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void input() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
}
void slove() {
long long n;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
long long ans = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= ans) {
++ans;
}
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t = 1;
while (t--) {
slove();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<long long> l;
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
l.push_back(x);
}
sort(l.begin(), l.end());
long long mex = 1;
for (int i = 0; i < l.size(); i++) {
if (l[i] >= mex) mex++;
}
cout << mex << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a[100001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> a[i];
sort(a, a + n);
long long ans = 1;
for (int i = 0; i < n; ++i) {
if (a[i] >= ans) ans++;
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long mod = 1e9 + 7;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n, k = 1;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
for (int i = 0; i < n; i++)
if (a[i] >= k) k++;
cout << k << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> arr;
for (int i = 0, v; i < n; ++i) {
scanf("%d", &v);
arr.push_back(v);
}
sort(arr.begin(), arr.end());
int ans = 1;
for (int i = 0; i < arr.size(); ++i)
if (arr[i] >= ans) ++ans;
printf("%d\n", ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int a[100005];
while (scanf("%d", &n) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
int ans = 0;
for (int i = 0; i < n; i++) {
if (a[i] > ans) ans++;
}
printf("%d\n", ans + 1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int ara[n];
int ans = 0;
for (int i = 0; i < n; i++) scanf("%d", &ara[i]);
sort(ara, ara + n);
for (int i = 0; i < n; i++) {
ans = min(ans + 1, ara[i]);
}
printf("%d", ans + 1);
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int INF = 0x3f7f7f7f;
struct node {
int val, id;
} a[MAXN];
int c[MAXN];
int b[MAXN];
bool cmp(node x, node y) { return x.val < y.val; }
int main() {
int n, i, j, m, ans;
while (scanf("%Id", &n) != EOF) {
memset(b, 0, sizeof(b));
for (i = 1; i <= n; i++) {
scanf("%d", &a[i].val);
a[i].id = i;
c[i] = i;
}
int cnt = 1;
sort(a + 1, a + 1 + n, cmp);
for (i = 1; i <= n; i++) {
if (b[cnt] == 0) {
if (cnt <= a[i].val) b[cnt++] = 1;
}
}
printf("%d\n", cnt);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n) {
if (n <= 1) return false;
if (n <= 3) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0) return false;
return true;
}
int nextPrime(int N) {
if (N <= 1) return 2;
int prime = N;
bool found = false;
while (!found) {
prime++;
if (isPrime(prime)) found = true;
}
return prime;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int test_case;
test_case = 1;
while (test_case--) {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
long long int ch = 1;
for (int i = 0; i < n; i++) {
if (ch <= a[i]) {
ch++;
}
}
cout << ch;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n;
cin >> n;
long long int ar[n];
for (long long int i = 0; i < n; i++) {
cin >> ar[i];
}
sort(ar, ar + n);
long long int c = 1;
for (long long int i = 0; i < n; i++) {
if (ar[i] >= c) c++;
}
cout << c;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int ans = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= ans) {
ans++;
continue;
}
}
cout << ans << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const int mod = 1000 * 1000 * 1000 + 7;
inline int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
inline void inc(int &a, int b) { a = add(a, b); }
inline int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
inline void dec(int &a, int b) { a = sub(a, b); }
void start_func() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void solve() {
int n;
cin >> n;
int ans = 1, i;
vector<int> arr;
for (i = 1; i <= n; i++) {
int a;
cin >> a;
arr.push_back(a);
}
sort(arr.begin(), arr.end());
for (i = 1; i <= n; ++i) {
if (arr[i - 1] < ans) {
continue;
}
ans++;
}
cout << ans << '\n';
}
signed main() {
start_func();
int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int x = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= x) {
x++;
}
}
cout << x << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
if (a > b)
return a;
else
return b;
}
int min(int a, int b) {
if (a < b)
return a;
else
return b;
}
void solve() {}
int main() {
int n;
cin >> n;
int k = n;
vector<long long> v(n);
int i = 0;
while (n--) {
cin >> v[i++];
}
sort(v.begin(), v.end());
long long j = 0;
for (i = 0; i < k; i++) {
j = min(++j, v[i]);
}
cout << ++j;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int z[1000005];
int main() {
int n, a, i;
i = 1;
cin >> n;
for (a = 0; n > a; a++) {
cin >> z[a];
}
qsort(z, n, sizeof(z[0]), cmp);
for (a = 0; n > a; a++) {
if (z[a] >= i) {
i++;
}
}
cout << i << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin >> n;
long long x[n + 5];
for (long long i = 0; i < n; i++) {
cin >> x[i];
}
sort(x, x + n);
if (x[0] != 1) {
x[0] = 1;
}
for (long long i = 1; i < n; i++) {
if (x[i] - x[i - 1] > 1) {
x[i] = x[i - 1] + 1;
}
}
cout << x[n - 1] + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void try_combine(map<int, int> &m, int k) {
if (m.count(k + m[k])) {
int l = k + m[k];
m[k] += m[l];
m.erase(l);
}
}
int ssum(int a, const pair<int, int> &b) { return a + b.second; }
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
int n, i, x;
map<int, int> m;
int a[100000];
cin >> n;
for (i = 0; i < n; i++) {
cin >> x;
a[i] = x;
}
qsort(&a, n, sizeof(int), cmp);
for (i = 0; i < n; i++) {
x = a[i];
if (x > n) x = n;
x = n - x;
bool f = false;
for (auto it = m.begin(); it != m.end(); it++) {
if (it->first <= x && x < it->first + it->second) {
int k = it->first;
if (k + m[k] + 1 <= n) {
m[k]++;
}
try_combine(m, k);
f = true;
break;
}
}
if (not f) {
m[x] = 1;
try_combine(m, x);
}
}
x = accumulate(m.begin(), m.end(), 1, ssum);
cout << x;
}
|
#include <bits/stdc++.h>
using namespace std;
int A[100001];
int main() {
int N;
scanf("%d", &N);
for (int Ni = 1; Ni <= N; Ni++) scanf("%d", &A[Ni]);
sort(A + 1, A + N + 1);
int num = 1;
for (int Ni = 1; Ni <= N; Ni++) {
if (A[Ni] >= num) {
num++;
}
}
printf("%d\n", num);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, ara[100009], i;
cin >> n;
for (i = 0; i < n; i++) cin >> ara[i];
sort(ara, ara + n);
ara[0] = 1;
for (i = 1; i < n; i++) {
if (ara[i] > ara[i - 1]) ara[i] = ara[i - 1] + 1;
}
cout << ara[n - 1] + 1;
}
|
#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) {
return (b ? gcd(b, a % b) : a);
}
inline long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
inline int cmp(double x, double y = 0, double tol = 1e-7) {
return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
using namespace std;
const int MAXN = 300005;
int main() {
long long n;
cin >> n;
vector<long long> v;
for (int i = 0, x; i < n; i++) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
if (v[0] != 1) v[0] = 1;
for (int i = 1; i < n; i++) {
if (v[i] - v[i - 1] > 1) v[i] = v[i - 1] + 1;
}
cout << v[n - 1] + 1 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t = 1;
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while (t--) {
long long int n, q, m, b, x, y, sum = 0, start = 0, end = 0;
cin >> n;
vector<int> v;
for (long int i = 0; i < n; i++) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
start = -1;
sum = 1;
for (long int i = 0; i < n; i++) {
if (v[i] > sum) {
if (start < sum) start = sum;
sum++;
} else if (v[i] == sum)
sum++;
}
cout << sum++;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
cin >> a;
long long int n[a];
for (int i = 0; i < a; i++) {
cin >> n[i];
}
sort(n, n + a);
int ans = 1;
int l = 1;
for (int i = 1; i <= a; i++) {
if (n[i - 1] >= l) {
ans = l + 1;
l++;
}
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
const long long int INF = 1e18L + 5;
using namespace std;
void input() {}
long long p1(long long base, long long power) {
long long res = 1;
while (power != 0) {
if (power % 2 == 0) {
base = ((base % 1000000007) * (base % 1000000007)) % 1000000007;
power = floor(power / 2);
} else {
res = ((res % 1000000007) * (base % 1000000007)) % 1000000007;
power = power - 1;
}
}
return res;
}
bool compare(long long a, long long b) { return a > b; }
long long facet(long long x) {
long long facto = 1;
for (long long i = 1; i <= x; i++) {
facto *= i;
}
return facto;
}
bool square(long long x) {
long long k = sqrt(x);
return k * k == x;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long n;
cin >> n;
long long a[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
long long cur = 1;
for (long long i = 0; i < n; i++) {
if (a[i] >= cur) {
cur++;
}
}
cout << cur << "\n";
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1000000007;
int a[100005];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) scanf("%d", &(a[i]));
sort(a, a + n);
int ans = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
int main() {
int n, x;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", &x), arr.push_back(x);
sort(arr.begin(), arr.end());
int last = 1;
for (int i = 0; i < n; i++)
if (arr[i] >= last) last++;
printf("%d\n", last);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a[100010];
int main() {
int i, j, Ans = 0;
scanf("%d", &n);
for (i = 1; i <= n; i++) scanf("%d", &a[i]);
sort(a + 1, a + 1 + n);
for (i = 1; i <= n; i++)
if (a[i] > Ans) Ans++;
printf("%d\n", Ans + 1);
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
int n, max = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (max < a[i]) max++;
}
cout << max + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long OO = (long long)1e18;
const int MOD = (int)1e9 + 7;
const long double Pi = 3.1415926535897932384626433832795;
const int N = (int)1e5 + 5;
int a[N], n;
int main() {
cin >> n;
for (int i = (int)(1); i <= (int)(n); i++) cin >> a[i];
sort(a + 1, a + n + 1);
for (int i = (int)(1); i <= (int)(n); i++) a[i] = min(a[i - 1] + 1, a[i]);
cout << a[n] + 1;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
int k;
vector<int> v;
while (t--) {
cin >> k;
v.push_back(k);
}
sort(v.begin(), v.end());
int cur = 1;
for (int i = 0; i < v.size(); i++) {
if (v[i] >= cur) cur++;
}
cout << cur << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7, N = 100000 + 9;
long long n, a[N], ans = 1;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (long long i = 0; i < n; ++i) {
cin >> a[i];
}
sort(a, a + n);
for (long long i = 0; i < n; ++i) {
if (a[i] >= ans) ++ans;
}
cout << ans;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100001;
int n, now = 1, arr[MAX];
int main() {
ios::sync_with_stdio(0);
cin >> n;
for (int i = 0; i < n; ++i) cin >> arr[i];
sort(arr, arr + n);
for (int i = 0; i < n; ++i)
if (arr[i] >= now) now++;
cout << now << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int z[100005];
int main() {
int n, a, i;
i = 1;
cin >> n;
for (a = 0; n > a; a++) {
cin >> z[a];
}
qsort(z, n, sizeof(z[0]), cmp);
for (a = 0; n > a; a++) {
if (z[a] >= i) {
i++;
}
}
cout << i << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int n, ans = 1;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
};
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, nums[100005], i, highest;
scanf("%I64d", &n);
for (i = 0; i < n; i++) scanf(" %I64d", &nums[i]);
sort(nums, nums + i);
nums[0] = 1;
for (i = 1; i < n; i++) {
if ((nums[i] - nums[i - 1]) >= 2) nums[i] = nums[i - 1] + 1;
}
printf("%I64d\n", nums[n - 1] + 1);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using pii = pair<int, ll>;
using vii = vector<pii>;
using vb = vector<bool>;
using vs = vector<string>;
const int N = 1e6 + 3;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vi a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
int cur = 1;
for (int i = 0; i < n; i++) {
if (cur <= a[i]) cur++;
}
cout << cur;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, c = 1;
cin >> n;
long long int* arr = new long long int[n];
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
for (int i = 0; i < n; i++) {
if (arr[i] > c) {
c++;
} else if (arr[i] == c) {
c++;
}
}
cout << c << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
vector<long> a(n);
for (long(i) = 0; (i) < (n); (i)++) cin >> a[i];
sort((a).begin(), (a).end());
a[0] = 1;
for (long(i) = (1); (i) < (n); (i)++) {
if (a[i] != a[i - 1]) a[i] = a[i - 1] + 1;
}
cout << a.back() + 1 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long unsigned int n, temp;
vector<long long unsigned int> A;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for (long long unsigned int i = 0; i < n; i++) {
cin >> temp;
A.push_back(temp);
}
sort(A.begin(), A.end());
long long unsigned int current_min = 1;
for (long long unsigned int i = 0; i < A.size(); i++) {
long long unsigned int curr = A[i];
if (curr >= current_min) {
current_min++;
}
}
cout << current_min << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> b = a;
sort(b.begin(), b.end());
int x = 1;
for (int i = 1; i < n; i++) {
if (b[i] >= x + 1) {
b[i] = x + 1;
x++;
}
}
cout << x + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[1000005], n, ans;
int main() {
while (scanf("%d", &n) == 1) {
ans = 0;
for (register int i = 1; i <= n; i++) scanf("%d", &a[i]);
sort(a + 1, a + n + 1);
for (register int i = 1; i <= n; i++)
if (ans < a[i]) ans++;
printf("%d", ++ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int max_n = 111111, inf = 1111111111;
int n, x, a[max_n];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
sort(a, a + n);
x = 1;
for (int i = 0; i < n; ++i) {
if (x <= a[i]) {
++x;
}
}
printf("%d\n", x);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios ::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
while (cin >> n) {
int x;
int ans = 0;
vector<int> v;
while (n--) {
cin >> x;
v.push_back(x);
}
sort(v.begin(), v.end());
for (int x : v)
if (ans < x) ++ans;
cout << (++ans) << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MAX = 1e5 + 10;
const long long inf = 1e18 + 7;
long long a[MAX];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n, ans = 1;
cin >> n;
for (long long i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
for (long long i = 0; i < n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
if (y == 0) return 1;
long long temp = power(x, int(y / 2));
if (y % 2 == 0)
return (((temp % 1000000007) * temp) % 1000000007);
else
return ((((x * temp) % 1000000007) * temp) % 1000000007);
}
inline int countsetbit(int n) {
unsigned int count = 0;
while (n) {
n &= (n - 1);
count++;
}
return count;
}
inline int abs(int x) {
if (x < 0) return -x;
return x;
}
int main() {
int n;
cin >> n;
long long a[n + 1];
for (int i = (1); i <= (n); ++i) {
cin >> a[i];
}
a[0] = 0;
long long c = 0;
sort(a, a + n + 1);
for (int i = 1; i <= n; i++) {
if (a[i] == a[i - 1]) {
if (c < 0) c++;
} else if (a[i] != a[i - 1] + 1) {
c -= (a[i] - a[i - 1] - 1);
}
}
if (c >= 0)
cout << a[n] + 1 << endl;
else
cout << a[n] + c + 1 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ar[1000009], c = 0;
void f(int n) {
long long ans = 0;
for (long long i = 0; i < n; i++) {
scanf("%lld", &ar[i]);
}
sort(ar, ar + n);
int x = 1;
for (long long i = 0; i < n; i++) {
if (ar[i] >= x) x++;
}
cout << x << endl;
}
int main() {
int n;
while (scanf("%d", &n) != EOF) {
f(n);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<long long> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
int k = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= k) {
a[i] = k;
k++;
}
}
cout << a[n - 1] + 1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100100];
int main() {
int i, n;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n);
int sign = 1;
for (i = 0; i < n; i++) {
if (a[i] >= sign) {
a[i] = sign;
sign++;
}
}
printf("%d\n", sign);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, a[100000], max = -222, s = 0, i;
cin >> n;
for (i = 1; i <= n; i++) cin >> a[i];
sort(a, a + n + 1);
for (i = 1; i <= n; i++)
if (a[i] > i) a[i] = i;
for (i = 1; i < n; i++)
if (a[i + 1] > a[i] + 1) a[i + 1] = a[i] + 1;
for (i = 1; i <= n; i++)
if (a[i] > max) max = a[i];
cout << max + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Tk, typename Tv>
ostream& operator<<(ostream& os, const pair<Tk, Tv>& p) {
os << "{" << p.first << ',' << p.second << "}";
return os;
}
const int MAX = 100005;
const int MOD = 1000000000 + 7;
const int INF = 1000000000;
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
int mex = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= mex) {
a[i] = mex++;
} else {
a[i] = mex;
}
}
cout << mex << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
long long v[100008];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> v[i];
sort(v + 1, v + n + 1);
v[1] = 1;
for (int i = 2; i <= n; i++)
if (v[i] > v[i - 1] + 1) v[i] = v[i - 1] + 1;
cout << v[n] + 1;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double eps = 1e-9;
const int INF = 1e9 + 7;
const int MAXN = int(3e5 + 7);
int n, a[MAXN], ans;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
a[0] = 1;
for (int i = 1; i < n; i++) {
if (a[i] > a[i - 1]) a[i] = a[i - 1] + 1;
}
cout << a[n - 1] + 1 << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int i, arr[100005];
for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
sort(arr, arr + n);
int j = 0;
for (i = 0; i < n; i++) {
j++;
if (arr[i] < j) j--;
}
cout << j + 1 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> input(n);
for (int& x : input) cin >> x;
sort(input.begin(), input.end());
int cnt{1};
for (int i = 0; i < n; ++i) {
if (input[i] >= cnt) ++cnt;
}
cout << cnt;
}
|
#include <bits/stdc++.h>
using namespace std;
const int M = 10e9 + 7;
long long bigmod(long long p, long long q, long long m) {
if (q == 0)
return 1;
else if (q % 2 != 0)
return ((p % m) * bigmod(p, q - 1, m) % m) % m;
else {
long long c = bigmod(p, q / 2, m) % m;
return ((c % m) * (c % m)) % m;
}
}
bool isprime(long long n) {
for (long long i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
long long a[523456];
int main() {
long long n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
long long ans = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= ans) ans++;
}
cout << ans << '\n';
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
int a[100001];
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
for (int i = 0; i < (n); i++) {
cin >> a[i];
}
sort(a, a + n);
int cur = 1;
for (int i = 0; i < (n); i++) {
if (a[i] == cur) {
cur++;
continue;
} else if (a[i] > cur) {
a[i]--;
cur++;
}
}
cout << cur;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool b[100005] = {0};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int i, a[n];
for (i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
int j = 1;
for (i = 0; i < n; i++) {
if (a[i] >= j) {
b[j] = 1;
j++;
}
}
for (j = 1; j <= 100005; j++) {
if (b[j] == 0) {
cout << j;
break;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int c = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= c) {
c++;
}
}
cout << c << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
long long n, x;
vector<long long> v;
vector<pair<long long, long long> > v2;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
v.push_back(x);
}
sort(begin(v), end(v));
long long bs = 0;
for (int i = 0; i < v.size(); i++) {
if (v[i] >= i + 1 - bs)
v[i] = i + 1 - bs;
else
bs++;
}
cout << 1 + v.back() << endl;
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = 1000001000;
const long long INFLL = INF * 1LL * INF;
const int mod = 1000 * 1000 * 1000 + 7;
const int mod9 = 1000 * 1000 * 1000 + 9;
const int modr = 99990001;
const long double PI = 3.1415926535897932385;
template <class T>
void zero(T val, T& first) {
first = val;
}
template <class T, class... Targs>
void zero(T val, T& first, Targs&... Fargs) {
first = val;
zero(val, Fargs...);
}
template <class T, class T2>
std::istream& operator>>(std::istream& is, pair<T, T2>& p) {
return is >> p.first >> p.second;
}
template <class T>
std::istream& readN(T& first, int n, int st = 0) {
for (int i = st, iend = (st + n - 1); i <= iend; i++) cin >> first[i];
return cin;
}
template <class T>
std::istream& readS(set<T>& first, int n) {
T second = *first.rbegin();
for (int i = 0, iend = (n - 1); i <= iend; i++) {
cin >> second;
first.insert(second);
}
return cin;
}
template <class T>
std::istream& read(T& first) {
return cin >> first;
}
template <class T, class... Targs>
std::istream& read(T& first, Targs&... Fargs) {
return read(first), read(Fargs...);
}
template <class T, class T2>
std::ostream& operator<<(std::ostream& os, pair<T, T2> p) {
return os << p.first << " " << p.second;
}
template <class T>
std::ostream& operator<<(std::ostream& os, vector<T> v) {
bool f = true;
for (auto second : v) {
if (!f) os << ' ';
os << second;
f = false;
}
return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, set<T> v) {
bool f = true;
for (auto second : v) {
if (!f) os << ' ';
os << second;
f = false;
}
return os;
}
template <class T>
std::ostream& operator<<(std::ostream& os, multiset<T> v) {
bool f = true;
for (auto second : v) {
if (!f) os << ' ';
os << second;
f = false;
}
return os;
}
template <class T, class T2>
std::ostream& operator<<(std::ostream& os, map<T, T2> v) {
bool f = true;
for (pair<T, T2> second : v) {
if (!f) os << ' ';
os << second.first << '=>' << second.second;
f = false;
}
return os;
}
template <class T>
std::ostream& outV(T first, char del = ' ') {
bool f = true;
for (auto second : first) {
if (!f) cout << del;
cout << second;
f = false;
}
return cout;
}
template <class T>
std::ostream& outN(T first, int n = -1, int st = 0) {
for (int i = st, iend = (n == -1 ? (int)first.size() - 1 : st + n - 1);
i <= iend; i++) {
cout << first[i];
if (i < iend) cout << ' ';
}
return cout;
}
template <class T>
std::ostream& outAN(T first, int n = -1, int st = 0) {
for (int i = st, iend = (n - 1); i <= iend; i++) {
cout << first[i];
if (i < iend) cout << ' ';
}
return cout;
}
template <class T>
std::ostream& out(T first) {
return cout << first;
}
template <class T, class... Targs>
std::ostream& out(T first, Targs... Fargs) {
return out(first) << " ", out(Fargs...);
}
template <typename T>
void srt(T& a, int st, int fn, bool isArr) {
sort(a + st, a + fn + 1);
}
template <class T>
void srt(T& a, int st = 0, int fn = 0) {
sort(a.begin() + st, fn ? a.begin() + fn + 1 : a.end());
}
template <typename T>
T rev_num(T a) {
T r = 0;
for (; a; a /= 10) r = r * 10 + a % 10;
return r;
}
template <typename T>
void rev(T& a, int st, int fn, bool isArr) {
reverse(a + st, a + fn + 1);
}
template <class T>
void rev(T& a, int st = 0, int fn = 0) {
reverse(a.begin() + st, fn ? a.begin() + fn + 1 : a.end());
}
long long phi(int n) {
int res = n;
for (long long i = 2; i * i <= n; i++)
if (n % i == 0) {
while (n % i == 0) n /= i;
res -= res / i;
}
if (n > 1) res -= res / n;
return res;
}
long long bpm(long long a, long long n = -2, long long m = mod) {
n = n < 0 ? n + m : n;
long long r = 1;
while (n) {
if (n & 1) r = (r * a) % m;
a = (a * a) % m;
n >>= 1;
}
return r;
}
unsigned long long gcd(unsigned long long a, unsigned long long b) {
while (b) {
a %= b;
swap(a, b);
}
return a;
}
vector<int> ero_p, ero_l;
void ero(int n) {
ero_l.resize(n + 1);
ero_l[0] = -1;
for (int i = 2, iend = (n); i <= iend; i++)
if (!ero_l[i]) {
ero_p.push_back(i);
ero_l[i] = i;
for (long long j = i * 1LL * i; j <= n; j += i) {
ero_l[j] = i;
}
}
}
long long gcd_cb(long long a, long long b, long long& first,
long long& second) {
if (!b) {
first = 1;
second = 0;
return a;
}
long long x1, y1, g;
g = gcd_cb(b, a % b, x1, y1);
first = y1;
second = x1 - a / b * y1;
return g;
}
vector<long long> fact;
void fact_prec(int n = 20) {
fact.resize(n + 1);
fact[0] = 1;
for (int i = 1, iend = (n); i <= iend; i++) {
fact[i] = fact[i - 1] * i;
}
}
vector<long double> factd;
void fact_precd(int n = 146) {
factd.resize(n + 1);
factd[0] = 1;
for (int i = 1, iend = (n); i <= iend; i++) {
factd[i] = factd[i - 1] * i;
}
}
string str(long long a) {
string r = "";
for (; a; a /= 10) r += a % 10 + '0';
rev(r);
return r;
}
const int N = 400005;
long long a[N], b[N];
int main() {
int n;
read(n);
readN(a, n);
sort(a, a + n);
int mx = 1;
for (int i = 0; i < n; i++) {
if (a[i] >= mx) {
mx++;
}
}
out(mx) << "\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
int m = 1;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
sort(a, a + n);
for (int i = 0; i < n; i++) {
if (a[i] >= m) m++;
}
cout << m << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
long long int num[MAX];
int main() {
long long int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> num[i];
}
sort(num, num + n);
for (int i = 0; i < n; i++) {
if (i == 0) {
if (num[i] != 1) {
num[i] = 1;
}
} else {
if (num[i] > num[i - 1]) {
num[i] = num[i - 1] + 1;
}
}
}
cout << num[n - 1] + 1 << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
long long a[100050];
for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
sort(a, a + n);
long long k = 0;
for (int i = 0; i < n; i++) {
if (a[i] > k) k++;
}
printf("%I64d\n", k + 1);
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.