text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; void solve() { int n, i, k = 1, c, d; cin >> n; int a[n]; map<int, int> m; for (i = 0; i < n; i++) { cin >> a[i]; m[a[i]]++; } sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] >= k) k++; } cout << k << endl; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); long long n, i, j, k, x, y, z, b; cin >> n; vector<long long> a; for (i = 0; i < n; i++) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); a[0] = 1; for (i = 1, b = 2; i < n; i++) { if (a[i] != a[i - 1]) { a[i] = b; b++; } } z = a[n - 1]; z++; cout << z; return 0; }
#include <bits/stdc++.h> using namespace std; long long inv(long long a, long long p) { long long temp = 1; while (p != 0) { if (p % 2 == 1) temp = (temp * a) % 1000000007; a = ((long long)a * a) % 1000000007; p = p / 2; } return temp; } int main() { long long n; cin >> n; int ar[100000]; for (int i = 0; i < n; i++) { cin >> ar[i]; } sort(ar, ar + n); int num = 1; int ind = 0; while (ind < n) { if (ar[ind] >= num) { ar[ind] = num; num++; } ind++; } cout << ar[n - 1] + 1; return 0; }
#include <bits/stdc++.h> using namespace std; long long Power(long long a, long long n, long long mod) { long long res = 1; while (n) { if (n % 2 != 0) { res = ((res % mod) * (a % mod)) % mod; n--; } else { a = ((a % mod) * (a % mod)) % mod; n /= 2; } } return res; } bool isPrime(long long n) { if (n <= 1) return false; if (n <= 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; for (long long i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; } long long getSum(long long n) { long long sum = 0; while (n != 0) { sum = sum + n % 10; n = n / 10; } return sum; } long long myceil(long long n, long long x) { long long y; if (n % x == 0) { y = n / x; return y; } else { y = n / x + 1; return y; } } long long md = 1000000007; vector<long long> fact, inv; void inverse(long long n) { if (n >= inv.size()) { long long size = inv.size(); size = size == 0 ? 1 : size; inv.resize(n + 1); inv[0] = 1; for (long long i = size; i <= n; i++) inv[i] = Power(fact[i], md - 2, md); } } void factorial(long long n) { if (n >= fact.size()) { long long size = fact.size(); size = size == 0 ? 1 : size; fact.resize(n + 1); fact[0] = 1; for (long long i = size; i <= n; i++) fact[i] = (fact[i - 1] * i) % md; } } long long ncr(long long n, long long r) { return (((fact[n] * inv[r]) % md) * inv[n - r]) % md; } long long primes[1300000]; void Sieve() { bool IsPrime[1300000]; memset(IsPrime, true, sizeof(IsPrime)); for (long long p = 2; p * p < 1300000; p++) { if (IsPrime[p] == true) { for (long long i = p * p; i < 1300000; i += p) IsPrime[i] = false; } } long long index = 0; for (long long p = 2; p < 1300000; p++) if (IsPrime[p]) { primes[index] = p; index++; } } long long __gcd(long long a, long long b) { if (b == 0) { return a; } long long ans = __gcd(b, a % b); return ans; } bool helper(pair<long long, long long> p1, pair<long long, long long> p2) { if (p1.first == p2.first) { return p1.second < p2.second; } return p1.first < p2.first; } void swap(long long* a, long long* b) { long long temp = *a; *a = *b; *b = temp; } bool IsSorted(vector<long long>& a) { long long n = a.size(); for (long long i = 1; i < n; i++) { if (a[i] < a[i - 1]) { return false; } } return true; } long long firstIndex(vector<long long>& a, long long x) { long long n = a.size(); for (long long i = 0; i < n; i++) { if (a[i] > x) { return i; } } return -1; } void solve() { long long n; cin >> n; vector<long long> arr(n); for (long long i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end()); long long key = 1; for (long long i = 0; i < n; i++) { if (arr[i] >= key) { arr[i] = key; key++; } } cout << key << "\n"; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int i, temp, n, a[100010]; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); temp = 1; for (i = 0; i < n; i++) { if (a[i] >= temp) { temp++; } } printf("%d\n", temp); } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> inline T bigmod(T b, T p, T m) { T ret; if (p == 0) return 1; if (p & 1) { ret = (bigmod(b, p / 2, m) % m); return ((b % m) * ret * ret) % m; } else { ret = (bigmod(b, p / 2, m) % m); return (ret * ret) % m; } } int dx4[] = {1, -1, 0, 0}; int dy4[] = {0, 0, 1, -1}; int dx6[] = {0, 0, 1, -1, 0, 0}; int dy6[] = {1, -1, 0, 0, 0, 0}; int dz6[] = {0, 0, 0, 0, 1, -1}; int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1}; int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2}; int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1}; int tc = 1; const double eps = 1e-9; const double pi = acos(-1.0); const long long int mx = 1e5; const long long int mod = 1e9 + 7; long long a[mx + 5]; int main() { long long i, n, mini; while (cin >> n) { for (i = 1; i <= n; i++) { scanf("%lld", &a[i]); } sort(a + 1, a + n + 1); mini = 1; for (i = 1; i <= n; i++) { if (a[i] >= mini) mini++; } cout << mini << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int a[N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", a + i); } sort(a, a + n); int p = 0; for (int i = 1;; i++) { while (a[p] < i && p < n) p++; if (p >= n) { printf("%d\n", i); return 0; } p++; } return 0; }
#include <bits/stdc++.h> using namespace std; int n; int a[100005]; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int ans = 1; for (int i = 0; i < n; i++) { if (ans <= a[i]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct cmp1 { bool operator()(int &a, int &b) { return a > b; } }; int main() { int n, w; scanf("%d", &n); priority_queue<int, vector<int>, cmp1> q; for (int i = 1; i <= n; i++) { scanf("%d", &w); q.push(w); } int e = 1; while (!q.empty()) { int o = q.top(); q.pop(); if (o >= e) e++; } printf("%d\n", e); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> a(n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } sort(a.begin(), a.end()); int cur = 1; for (int x : a) { if (x >= cur) { ++cur; } } printf("%d\n", cur); return 0; }
#include <bits/stdc++.h> using namespace std; const long long inf = 1e18; const long long ninf = -1 * inf; long long dx[4] = {1, -1, 0, 0}; long long dy[4] = {0, 0, 1, -1}; char dir[4] = {'D', 'U', 'R', 'L'}; struct Node { long long x, y, l, r; }; void solve(long long ca) { long long n; cin >> n; vector<long long> vec(n); for (long long i = 0; i < n; i++) cin >> vec[i]; sort(vec.begin(), vec.end()); long long x = 1; for (long long i = 0; i < n; i++) { if (vec[i] >= x) x++; } cout << x; } int main() { cin.tie(NULL); ios_base::sync_with_stdio(false); long long t = 1, ca; ca = 1; while (t--) { solve(ca); ca++; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<long long int> a; for (int i = 1; i <= n; i++) { long long int b; cin >> b; a.push_back(b); } sort(a.begin(), a.end()); int cur = 1; for (int i = 0; i < n; i++) { if (a[i] >= cur) cur++; } cout << cur; }
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; const int N = 1e5 + 10; multiset<int> ms; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; ms.insert(x); } int cur = 1; while (!ms.empty()) { if (cur <= *ms.begin()) { ms.erase(ms.find(*ms.begin())); cur++; } else { ms.erase(ms.find(*ms.begin())); } } cout << cur << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool cmp(long long g, long long h) { return g < h; } int main() { long long k, a[100005], b, n, i, p, x, m, j; long long cnt = 0; char str[100]; scanf("%lld", &n); for (i = 1; i <= n; i++) { scanf("%lld", &a[i]); } sort(a, a + n + 1, cmp); for (i = 1; i <= n; i++) { if (a[i] > a[i - 1]) a[i] = a[i - 1] + 1; } printf("%lld\n", a[n] + 1); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> vec(n); for (auto &it : vec) { cin >> it; } sort(vec.begin(), vec.end()); int mex = 1; for (auto it : vec) { if (it >= mex) { mex++; } } cout << mex << '\n'; }
#include <bits/stdc++.h> using namespace std; int Set(int N, int pos) { return N = N | (1 << pos); } int check(int N, int pos) { return N & (1 << pos); } bool isLinier(int a, int b, int m, int n, int x, int y) { int t1, t2; t1 = (n - b) * (x - m); t2 = (y - n) * (m - a); if (t1 == t2) return true; else return false; } struct line { void values(double x, double y, double z) { a = x, b = y, c = z; } double a, b, c; }; pair<double, double> sectionPoint(line l1, line l2) { double a1, b1, c1, a2, b2, c2, x, y, dx, dy, d; a1 = l1.a, b1 = l1.b; c1 = l1.c; a2 = l2.a; b2 = l2.b; c2 = l2.c; d = a1 * b2 - b1 * a2; if (d == 0) return make_pair(-1, -1); dx = c1 * b2 - c2 * b1; dy = a1 * c2 - a2 * c1; x = dx * 1.0 / d; y = dy * 1.0 / d; cout << x << endl << y << endl; return make_pair(x, y); } line equation(pair<double, double> point1, pair<double, double> point2) { double x1, x2, y1, y2; x1 = point1.first; y1 = point1.second; x2 = point2.first; y2 = point2.second; double kx, ky; line ret; kx = x1 - x2; ky = y1 - y2; ret.a = ky; ret.b = kx; ret.c = x1 * ky - y1 * kx; if (ret.a < 0) { ret.a *= -1; ret.b *= -1; ret.c *= -1; } cout << ret.a << "x+" << ret.b << "y=" << ret.c << endl; return ret; } double const eps = 1e-9; long long manhattan(long long x1, long long y1, long long x2, long long y2) { return abs(x1 - x2) + abs(y1 - y2); } int bigPow(int a, int b, int m) { if (b == 1) return a % m; if (b == 0) return 1; long long res = bigPow(a, b / 2, m); res = (res * res) % (long long)m; if (b % 2) res = (res * a % m) % m; return res; } int MMI_Fermat(int a, int m) { return bigPow(a, m - 2, m); } void ext_euclid(long long a, long long b, long long &x, long long &y, long long &g) { x = 0, y = 1, g = b; long long m, n, q, r; for (long long u = 1, v = 0; a != 0; g = a, a = r) { q = g / a, r = g % a; m = x - u * q, n = y - v * q; x = u, y = v, u = m, v = n; } } long long mod_inv(long long n, long long m) { long long x, y, gcd; ext_euclid(n, m, x, y, gcd); if (gcd != 1) return 0; return (x + m) % m; } long long crt(vector<long long> &a, vector<long long> &x) { long long z = 0; long long n = 1; for (int i = 0; i < x.size(); ++i) n *= x[i]; for (int i = 0; i < a.size(); ++i) { long long tmp = (a[i] * (n / x[i])) % n; tmp = (tmp * mod_inv(n / x[i], x[i])) % n; z = (z + tmp) % n; } return (z + n) % n; } int nod(int n) { if (n == 1) return 1; int lim = sqrt(n); int gun = 1; for (int i = 2; i <= lim; i++) { if (n % i) continue; int c = 0; while (n % i == 0) { c++; n /= i; } gun *= (c + 1); } if (n != 1) gun *= 2; return gun; } long long sod(int n) { if (n == 1) return 1; int lim = sqrt(n); long long gun = 1; for (int i = 2; i <= lim; i++) { if (n % i) continue; long long temp = i; while (n % temp == 0) { temp *= i; } n /= (temp / i); gun *= (temp - 1) / (i - 1); } if (n != 1) gun *= n + 1; return gun; } int ache[1000000 + 5]; int main() { long long testCase, x, y, m, l, k, b, c, z, n, mx = -1; memset(ache, false, sizeof(ache)); cin >> n; for (int i = 0; i < n; i++) { cin >> ache[i]; } sort(ache, ache + n); int res = 1; for (int i = 0; i < n; i++) { if (ache[i] >= res) res++; } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100001], b[100001], n; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); b[0] = 1; for (int i = 1; i < n; i++) { b[i] = b[i - 1]; if (a[i] > b[i - 1]) b[i]++; } printf("%d", b[n - 1] + 1); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long int n, answer = 0, k = 1; cin >> n; if (n == 1) { cout << 2 << endl; return; } vector<long long int> arr(n); for (long long int i = 0; i < n; ++i) cin >> arr[i]; sort(arr.begin(), arr.end()); for (long long int i = 0; i < n; ++i) { if (arr[i] >= k) arr[i] = k++; } sort(arr.begin(), arr.end()); k = 1; for (long long int i = 0; i < n; ++i) { if (arr[i] == k) k++; } answer = k; cout << answer << endl; } int main() { solve(); }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int ara[n]; for (long long int i = 0; i < n; i++) cin >> ara[i]; sort(ara, ara + n); long long int cnt = 1; for (long long int i = 1; i < n; i++) { if (ara[i] > cnt) { cnt++; } } cout << cnt + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; bool vis[100005]; int arr[100005]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); int need = 1; for (int i = 0; i < n; i++) { if (arr[i] > need) { arr[i] = need; need++; } else if (arr[i] == need) { need++; } else { ; } } cout << need << endl; } int main() { solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int i, j, k; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (i = 0, j = 0; i < n; i++, j++) { if (j + 1 > n) { cout << i + 1 << "\n"; return 0; } if (arr[j] < (i + 1)) { i--; } } cout << n + 1 << "\n"; return 0; }
#include <bits/stdc++.h> int a[1000010]; using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int q = 1; for (int i = 0; i < n; i++) if (a[i] >= q) q++; cout << q << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int mxi = 1e7 + 10; const int mod = 1e9 + 7; long long a, b = 1, n[mxi]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> a; for (int i = 0; i < a; i++) { cin >> n[i]; } sort(n, n + a); for (int i = 0; i < a; i++) { if (n[i] >= b) b++; } cout << b; }
#include <bits/stdc++.h> using namespace std; int n; int a[100010]; int ans; 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 (ans < a[i]) ans++; cout << ans + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count()); long long rnd(long long l, long long r) { return (mt_rnd_64() % (r - l + 1)) + l; } const int N = 1e5 + 5; int n, l = 0; int a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(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 (a[i] >= l + 1) a[i] = l + 1; l = a[i]; } for (int i = 1; i < n; i++) { if (a[i] > a[i - 1] + 1) return cout << a[i - 1] + 1, 0; } cout << a[n - 1] + 1; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, i, j, a[100100], p = 1; scanf("%lld", &n); for (i = 0; i < n; i++) scanf("%lld", &a[i]); sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] >= p) p++; } printf("%lld\n", p); return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T1, typename T2> istream &operator>>(istream &stream, pair<T1, T2> &p) { stream >> p.first >> p.second; return stream; } template <typename T1, typename T2> ostream &operator<<(ostream &stream, const pair<T1, T2> &p) { stream << p.first << ' ' << p.second; return stream; } template <typename T> istream &operator>>(istream &stream, vector<T> &vec) { for (size_t i = 0; i < vec.size(); i++) { stream >> vec[i]; } return stream; } template <typename T> ostream &operator<<(ostream &stream, const vector<T> &vec) { for (size_t i = 0; i < vec.size(); i++) { if (i) { stream << ' '; } stream << vec[i]; } return stream; } template <typename T> class MapSmartAccessorWrapper { T &m; public: MapSmartAccessorWrapper(T &m) : m(m) {} typename T::mapped_type &operator[](const typename T::key_type &key) { return m[key]; } typename T::mapped_type operator[](const typename T::key_type &key) const { auto it = m.find(key); if (it == m.end()) { return typename T::mapped_type(); } return it->second; } }; template <typename TKey, typename TValue> MapSmartAccessorWrapper<map<TKey, TValue> > operator++(map<TKey, TValue> &m, int i) { return m; } template <typename TKey, typename TValue> MapSmartAccessorWrapper<unordered_map<TKey, TValue> > operator++( unordered_map<TKey, TValue> &m, int i) { return m; } int main_file(string const &filename); int main(int argc, const char *argv[]) { ios_base::sync_with_stdio(false); int n; cin >> n; vector<int> v(n); cin >> v; sort(v.begin(), v.end()); int mex = 1; for (int i = 0; i < n; i++) { if (v[i] >= mex) { mex++; } } cout << mex; return 0; }
#include <bits/stdc++.h> using namespace std; int N, arr[100010]; void Debug() {} void Read() { cin >> N; for (int i = 1; i <= N; ++i) cin >> arr[i]; sort(arr + 1, arr + N + 1); } void Solve() { for (int i = 1; i <= N; ++i) if (arr[i] > arr[i - 1]) arr[i] = arr[i - 1] + 1; cout << arr[N] + 1 << "\n"; } int main() { Read(); Solve(); Debug(); return 0; }
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e9 + 7; int main() { int n, i, ans = 1, j, amax = -1; cin >> n; vector<int> A(n + 2, 0); for (i = 0; i < n; ++i) { int a; cin >> a; if (a > amax) amax = a; A[min(a, n + 1)]++; } for (int i = 1; i <= n; ++i) if (A[i] <= 0) { A[i + 1] -= (1 - A[i]); A[i] = 1; }; cout << n + 1 + A[n + 1]; return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> V(n); for (int i = 0; i < (int)n; ++i) cin >> V[i]; sort(V.begin(), V.end()); int ans = 0; int c = 0; for (int i = 0; i < (int)n; ++i) { if (V[i] > c + 1) { V[i] = c + 1; c++; } else if (V[i] > c) { c = V[i]; } } cout << V[n - 1] + 1 << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int ara[n]; for (int i = 0; i < n; i++) cin >> ara[i]; sort(ara, ara + n); int cur = 1; for (int i = 0; i < n; i++) { if (ara[i] >= cur) cur++; } cout << cur << endl; }
#include <bits/stdc++.h> using namespace std; int dir1[8][2] = {1, 2, 2, 1, 2, -1, 1, -2, -1, 2, -2, 1, -1, -2, -2, -1}; int dir2[4][2] = {1, 0, 0, 1, -1, 0, 0, -1}; int dir3[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1}; int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); } bool Isleap(int year) { if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) return true; return false; } bool isPrime(int x) { if (x == 1) return false; else if (x == 2) return true; for (int i = 2; i <= sqrt(x * 1.0); ++i) { if (x % i == 0) return false; } return true; } int sqr(int x) { return x * x; } vector<int> vt; int main() { int n; while (~scanf("%d", &n)) { vt.clear(); int x; for (int i = 0; i < n; ++i) { scanf("%d", &x); vt.push_back(x); } sort(vt.begin(), vt.end()); vt[0] = 1; for (int i = 1; i < n; ++i) { if (vt[i] > vt[i - 1] + 1) vt[i] = vt[i - 1] + 1; else if (vt[i] == vt[i - 1] + 1 || vt[i] == vt[i - 1]) continue; } printf("%d\n", vt[n - 1] + 1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long int n; cin >> n; long long arr[n]; for (long long i = 0; i < n; i++) cin >> arr[i]; vector<bool> visited(1000001, 0); long long ans = 1; sort(arr, arr + n); for (long long i = 0; i < n; i++) { if (arr[i] >= ans) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int n, x; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &x); v.push_back(x); } sort(v.begin(), v.end()); int pick = v[0], counter = 2; for (int i = 1; i < v.size(); i++) { if (v[i - 1] < v[i]) v[i] = ++pick; if (v[i] >= counter) counter++; } printf("%d\n", counter); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int vetor[n]; for (int i = 0; i < n; ++i) cin >> vetor[i]; sort(vetor, vetor + n); int ans = 1; for (int i = 0; i < n; ++i) { if (vetor[i] >= ans) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; void maloosh_lazma() { ios_base::sync_with_stdio(false); cin.tie(NULL); } int main() { maloosh_lazma(); int n; cin >> n; int *x = new int[n]; for (int i = 0; i < n; i++) { cin >> x[i]; } sort(x, x + n); long long now = 1; for (int i = 0; i < n; i++) { if (x[i] >= now) { now++; } } cout << now; return 0; }
#include <bits/stdc++.h> using namespace std; long long int a[100001]; int main() { ios_base::sync_with_stdio(false); int n; long long int ans = 1; cin >> 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; return 0; }
#include <bits/stdc++.h> using namespace std; long long mode(long long x, long long m) { return (x % m + m) % m; } long long mod = 1000000007; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long n; cin >> n; long long ar[n]; for (long long i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n); long long mini = 1; for (long long i = 0; i < n; i++) { if (ar[i] >= mini) { ar[i] = mini; mini++; } } for (long long i = 1; i <= n; i++) { if (!binary_search(ar, ar + n, i)) { cout << i; return 0; } } cout << n + 1; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int a[N]; for (int n = 0; n < N; n++) cin >> a[n]; sort(a, a + N); int q = 1; for (int n = 0; n < N; n++) { if (q <= a[n]) q = q + 1; } cout << q; return 0; }
#include <bits/stdc++.h> using namespace std; map<int, int> m; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); ; int n; cin >> n; int x; int c = 1; long *a = new long[n]; ; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); c = 1; for (int i = 0; i < n; i++) { if (c <= a[i]) c++; } cout << c; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); if (v[0] != 1) v[0] = 1; for (int i = 1; i < v.size(); i++) if (v[i] - v[i - 1] > 1) v[i] = v[i - 1] + 1; cout << v[v.size() - 1] + 1; }
#include <bits/stdc++.h> using namespace std; int n, a[100001]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int k = 1; for (int i = 0; i < n; i++) { if (a[i] >= k) a[i] = k, k++; } printf("%d", k); }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; int a[MAXN], N; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", &a[i]); int mex = 1; sort(a, a + N); for (int i = 0; i < N; i++) { if (a[i] >= mex) mex++; } printf("%d\n", mex); }
#include <bits/stdc++.h> using namespace std; long long n, r, avg, ans = 1, k, res, m, a[100100]; string second; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); int i = 1; while (i <= n) { if (a[i] >= ans) ans++; i++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int arr[200000]; int main() { int k; map<int, int> mapi; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> k; if (mapi[k] == 0) { mapi[k]++; } else { mapi[k]++; } } map<int, int>::iterator it; int cnt = 0; for (it = mapi.begin(); it != mapi.end(); it++) { int t1 = it->first; int t2 = it->second; if (t1 != cnt + 1) { if (t2 >= t1 - cnt) { cnt = t1; } else { cnt += t2; } } else { cnt++; } } cout << cnt + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; const int maxN = 1e5 + 10; int n, a[maxN], c[maxN], d[maxN], tot; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i], c[i] = a[i]; sort(c, c + n); tot = unique(c, c + n) - c; for (int i = 0; i < n; i++) d[lower_bound(c, c + tot, a[i]) - c]++; int ans = 0; for (int i = 0; i < tot; i++) { ans += d[i]; if (ans > c[i]) ans = c[i]; } cout << ans + 1; return 0; }
#include <bits/stdc++.h> using namespace std; int a[1000010]; int main() { int n, i, j, k; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } int curr = 1; sort(a, a + n); for (i = 0; i < n; i++) { if (a[i] >= curr) { curr++; } } cout << curr << endl; return 0; }
#include <bits/stdc++.h> using namespace std; struct node { int a, b; bool operator<(const node &n) const { return a < n.a; } }; int n, m, k; vector<int> v, v2, v3, v4; vector<char> vc; string s; deque<char> dq; map<char, int> mp; int a[30]; int main() { int t, t1; while (cin >> n) { v.clear(); for (int i = 0; i < n; i++) { cin >> t; v.push_back(t); } sort(v.begin(), v.end()); int cnt = 1; for (int i = 0; i < v.size(); i++) { if (v[i] >= cnt) { cnt++; } } cout << cnt << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int arr[100000], a, cnt; int main() { cin >> a; for (int i = 0; i < a; i++) cin >> arr[i]; sort(arr, arr + a); for (int i = 0; i < a; i++) if (arr[i] > cnt) cnt++; cout << cnt + 1; }
#include <bits/stdc++.h> using namespace std; int main() { int S, C = 1; cin >> S; int *N = new int[S]; for (int i = 0; i < S; i++) cin >> N[i]; sort(N, N + S); for (int i = 0; i < S; i++) if (N[i] >= C) C++; cout << C; }
#include <bits/stdc++.h> using namespace std; map<int, int> nn; set<int> x; int n, arr[100100]; int main() { cin >> n; for (int i = 1; i <= n; i++) { cin >> arr[i]; nn[arr[i]]++; x.insert(arr[i]); } for (int i = 1; i <= n + 1; i++) { if (nn[i] == 0) { if (x.upper_bound(i) == x.end()) { cout << i << endl; return 0; } nn[i]++; nn[*x.upper_bound(i)]--; if (nn[*x.upper_bound(i)] == 0) { x.erase(x.upper_bound(i)); } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, x; cin >> n; int a[n + 5]; for (i = 1; i <= n; i++) { cin >> a[i]; } sort(a + 1, a + n + 1); a[1] = 1; for (i = 2; i <= n; i++) { x = a[i]; if (a[i] > a[i - 1] + 1) { a[i] = a[i - 1] + 1; } if (a[i] > x) { a[i] = x; } } cout << a[n] + 1; return 0; }
#include <bits/stdc++.h> int main() { std::istream& is = std::cin; std::ostream& os = std::cout; int n, a, m; is >> n; std::vector<int> as; as.reserve(n); for (; n > 0; n--) { is >> a; as.push_back(a); } std::sort(as.begin(), as.end()); m = 0; for (auto ac : as) { if (m < ac) m++; } m++; os << m; }
#include <bits/stdc++.h> using namespace std; int a[100010]; int main() { int n; scanf("%d", &n); 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 (ans < a[i]) ans++; } printf("%d", ans + 1); return 0; }
#include <bits/stdc++.h> using namespace std; int n, cur, a[100005]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); cur = 1; for (int i = 0; i < n; i++) { if (a[i] >= cur) { cur++; } } printf("%d\n", cur); return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 100006; int a[N]; int n; int m; int b[5]; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int cur = 1; for (int i = 0; i < n; i++) { if (a[i] >= cur) { cur++; } } printf("%d", cur); return 0; }
#include <bits/stdc++.h> using namespace std; const long long N = 1e6 + 5; void solve() { long long n; cin >> n; vector<long long> v(n); for (auto &i : v) { cin >> i; } sort((v).begin(), (v).end()); long long mini = 1; for (auto &i : v) { if (mini <= i) { i = mini; mini++; } } cout << mini; } int32_t main() { long long t = 1; while (t--) { solve(); } 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); a[0] = 1; for (int i = 1; i < n; ++i) { if (a[i] != a[i - 1]) { a[i] = a[i - 1] + 1; } } printf("%d\n", a[n - 1] + 1); return 0; }
#include <bits/stdc++.h> using namespace std; const int MAX = 5 * 10000; const int MOD = 1e9 + 7; const double PI = 3.1415926535; double dist1(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } int dist(int x1, int y1, int x2, int y2) { return (abs(x1 - x2) + abs(y1 - y2)); } int main() { vector<int> v; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; v.push_back(x); } sort(v.begin(), v.end()); int c = 1; for (int i = 0; i < n; i++) { if (v[i] >= c) { v[i] = c; c++; } } cout << c; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int p = 0; vector<int> list; for (int i = 0; i < n; i++) { int ai; cin >> ai; list.push_back(ai); } sort(list.begin(), list.end()); vector<int>::iterator it; for (it = list.begin(); it != list.end(); it++) { if (*it > p) { p++; } } cout << p + 1 << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int N; long arr[100001]; int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); } int main() { cin >> N; for (long long i = 0; i < N; i++) { cin >> arr[i]; } qsort(arr, N, sizeof(long), compare); long needv = 1; for (long long i = 0; i < N; i++) { if (arr[i] >= needv) { arr[i] = needv; needv++; } } cout << needv; return 0; }
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1); int ar[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t, i, j, k, n, m = 0, mx = 0, cnt = 0, flg = 0, sum = 0, mn = 1e10, ans = 0; cin >> n; for (i = 0; i < n; i++) cin >> ar[i]; sort(ar, ar + n); for (i = 0; i < n; i++) if (ar[i] > m) { ar[i] = m + 1; m++; } cout << ar[n - 1] + 1; return 0; }
#include <bits/stdc++.h> using namespace std; int arr[100001], n, l; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &arr[i]); sort(arr, arr + n); l = 1; for (int i = 0; i < n; i++) { if (arr[i] > l) arr[i] = l, l++; else if (arr[i] == l) l++; else l = arr[i] + 1; } printf("%d", l); }
#include <bits/stdc++.h> using namespace std; vector<int> lt; int main() { int n, el; cin >> n; for (int i = 0; i < n; i++) { cin >> el; lt.push_back(el); } sort(lt.begin(), lt.end()); int pos = 0; int cand = 1; while (pos < n) { while (pos < n && lt[pos] < cand) { pos++; } if (pos == n) { break; } lt[pos] = cand; cand++; } cout << cand; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100100]; int b[100100]; int main() { int n; while (~scanf("%d", &n)) { for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, a + n); int sum = 0; memset(b, 0, sizeof(b)); a[0] = 1; b[1] = 1; for (int i = 0; i < n - 1; i++) { if (a[i + 1] - a[i] > 1) { a[i + 1] = a[i] + 1; } b[a[i + 1]] = 1; } int ans = -1; for (int i = 1; i <= 100001; i++) { if (b[i] == 0) { ans = i; break; } } printf("%d\n", ans); } }
#include <bits/stdc++.h> using namespace std; int main() { long long a[100000]; long long n, i; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; } sort(a, a + n); a[0] = 1; for (i = 1; i <= n - 1; i++) { if (a[i] == a[i - 1] || a[i] == a[i - 1] + 1) continue; else a[i] = a[i - 1] + 1; } cout << a[n - 1] + 1; return 0; }
#include <bits/stdc++.h> void Open() { freopen( "txt" ".in", "r", stdin); freopen( "txt" ".out", "w", stdout); } void Close() { fclose(stdin); fclose(stdout); } using namespace std; int Read() { int val = 0, opt = 1; char ch; while (!isdigit(ch = getchar())) if (ch == '-') opt = -1; while (isdigit(ch)) (val *= 10) += ch - '0', ch = getchar(); return val * opt; } int a[100100], n, Ans = 1; void work() { n = Read(); for (int i = 1; i <= n; i++) a[i] = Read(); sort(a + 1, a + 1 + n); for (int i = 1; i <= n; i++) if (a[i] >= Ans) Ans++; cout << Ans; } int main(void) { work(); return 0; }
#include <bits/stdc++.h> using namespace std; multiset<int> a; int main() { int n, x; cin >> n; for (int i = 0; i < n; i++) { cin >> x; a.insert(x); } int t = 1; while (true) { auto it = a.lower_bound(t); if (it == a.end()) break; t++; a.erase(it); } cout << t << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> v; for (int i = 0; i < n; i++) { int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end()); int cc = -1; int ii = 1; for (int i = 0; i < v.size(); i++) { if (v[i] >= ii) ii++; } cout << ii << endl; return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long i, j, k, n, m, T; cin >> n; long long arr[n + 1]; map<long long, long long> mp; for (i = 0; i < n; i++) { long long x; cin >> x; mp[x]++; arr[i] = x; } long long mex = 1; while (mp[mex]) mex++; sort(arr, arr + n); for (i = 0; i < n; i++) { if (arr[i] >= mex) { mp.erase(arr[i]); mp[mex] = 1; mex++; while (mp[mex]) mex++; } } cout << mex << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int g; cin >> g; v.push_back(g); } sort(v.begin(), v.end()); int f = 1; for (int i = 0; i < v.size(); i++) { if (v[i] == f) f++; else if (v[i] > f) v[i] = f, f++; } cout << f << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100010]; int b[100010]; int main() { int n; while (scanf("%d", &n) != EOF) { for (int i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + n + 1); int l = 1, r = 100010; int ans; while (l < r) { int mid = (l + r) / 2; int num = 1; int fg = 0; for (int i = 1; i <= n; i++) { if (num >= mid) { fg = 1; break; } if (a[i] == num) num++; else if (a[i] > num) num++; if (num >= mid) { fg = 1; break; } } if (fg) l = mid + 1, ans = mid; else r = mid; } printf("%d\n", ans); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; int num[1000005]; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%d", &num[i]); } sort(num + 1, num + 1 + n); num[1] = 1; for (int i = 2; i <= n; i++) { if (num[i] > num[i - 1]) { num[i] = num[i - 1] + 1; } } printf("%d\n", num[n] + 1); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[100005]; int main() { scanf("%d\n", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]); sort(a + 1, a + n + 1); int mex = INT_MAX; for (int i = 1; i <= n; ++i) if (a[i] > a[i - 1]) a[i] = a[i - 1] + 1; printf("%d", a[n] + 1); return 0; }
#include <bits/stdc++.h> const int64_t INF = 1000000000000000000; using namespace std; int main() { int n; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); int ans = 1; for (int i = 0; i < n; i++) { if (arr[i] >= ans) ans++; } cout << ans; return 0; }
#include <bits/stdc++.h> using namespace std; template <typename T> inline void gn(T &xx) { xx = 0; T xf = 1; char xch = getchar(); while (!isdigit(xch)) { if (xch == '-') xf = -1; xch = getchar(); } while (isdigit(xch)) { xx = xx * 10 + xch - '0'; xch = getchar(); } xx *= xf; } struct TT { int a; }; TT tt[5]; long long n, m, i, j, k, l, t, s, r, mmax, mmin, num, ans; long long MOD = 1e9 + 7, mod; long long ff[100011], dd[11]; int main() { scanf("%I64d", &n); for (i = 1; i <= n; i++) gn(ff[i]); sort(ff + 1, ff + n + 1); for (i = 1; i <= n; i++) { r = min(i, ff[i - 1] + 1); if (ff[i] >= r) ff[i] = r; else ff[i] = ff[i - 1]; } printf("%I64d\n", ff[n] + 1); return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[1000009]; set<int> s; int main() { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); int req = 1; for (int i = 0; i < n; i++) { if (a[i] >= req) { s.insert(req); req++; } } int curr = 1; for (set<int>::iterator it = s.begin(); it != s.end(); it++) { if (*it == curr) { curr++; } else break; } cout << curr << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, *a, c = 0; cin >> n; a = new int[n]; for (int i = 0; i < n; cin >> a[i++]) ; sort(a, a + n); for (int i = 0; i < n; i++) if (a[i] > c) a[i] = ++c; cout << c + 1; delete[] a; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[100050], cnt = 0; int main() { cin >> 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] > cnt) cnt++; cout << cnt + 1; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int n, a[N]; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int ans = 1; sort(a, a + n); for (int i = 0; i < n; i++) if (a[i] >= ans) a[i] = 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 (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + n + 1); long long Min = 0; for (int i = 1; i <= n; i++) { if (a[i] > Min + 1) { a[i] = Min + 1; Min = a[i]; } else if (a[i] == Min + 1) Min = a[i]; } cout << Min + 1 << endl; }
#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 sum = 1; for (int i = 0; i < n; i++) { if (sum <= a[i]) { sum++; } } cout << sum; }
#include <bits/stdc++.h> using namespace std; int sum_digit(long long x) { int ans = 0; while (x) { ans += x % 10; x /= 10; } return ans; } long long power(long long base, long long degree) { long long ans = 1; for (long long i = 0; i < degree; ++i) ans *= base; return ans; } int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) cin >> a[i]; sort(a.begin(), a.end()); 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; return 0; }
#include <bits/stdc++.h> using namespace std; int n, a[100001]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; sort(a + 1, a + 1 + n); if (a[1] > 1) a[1] = 1; for (int i = 2; i <= n; i++) if (a[i] > a[i - 1]) a[i] = a[i - 1] + 1; cout << a[n] + 1; return 0; }
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0, _n = (n); i != _n; i++) cin >> a[i]; sort((a).begin(), (a).end()); int mex(1); for (int i = 0, _n = (n); i != _n; i++) if (a[i] >= mex) mex++; cout << mex; return 0; }
#include <bits/stdc++.h> using namespace std; long long n, arr[1000006], cur; map<long long, bool> b; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> arr[i]; sort(arr + 1, arr + 1 + n); for (int i = 1; i <= n; i++) { if (arr[i] > cur) cur++; b[cur] = 1; } for (int i = 1; i <= 1e6 + 1; i++) { if (b[i] ^ 1) { cout << i << "\n"; break; } } }
#include <bits/stdc++.h> using namespace std; int main() { long n; cin >> n; vector<long> arr(n); for (long i = 0; i < n; i++) cin >> arr[i]; sort(arr.begin(), arr.end()); long count = 1; for (long i = 0; i < n; i++) { if (arr[i] >= count) count++; } cout << count << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long n, dem = 0; cin >> n; long long a[n + 10]; 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] > dem) { dem++; } } cout << dem + 1; }
#include <bits/stdc++.h> using namespace std; const int N = 100010; int n, m, a[N]; map<int, int> f; int main(int argc, char **argv) { cin >> n; for (int i = 1; i <= n; ++i) { scanf("%d", a + i); ++f[a[i]]; } sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) if (a[i] > a[i - 1]) a[i] = ++a[i - 1]; int ans = a[n] + 1; cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; long long int max = 0; long long 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] >= max + 1) max++; } cout << max + 1 << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; long long int gcd(long long int a, long long int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int n; cin >> n; long long int arr[100005]; long long int maxi = 1; int i; for (i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); for (i = 0; i < n; i++) { if (arr[i] >= maxi) { maxi++; } } cout << maxi << "\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int a[100010]; int main() { int Case = 1; int n, m, k; char dump[2]; while (scanf("%d", &n) == 1) { for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } sort(a + 1, a + 1 + n); int mn = 1; for (int i = 1; i <= n; i++) { if (mn < a[i]) { a[i] = mn; mn++; } else if (mn == a[i]) { mn++; } } printf("%d\n", mn); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s_begin = "I hate ", s_end = "it"; string y = "that I hate ", x = "that I love "; cout << s_begin; for (int i = 2; i <= n; i++) { if (i % 2 == 0) cout << x; else cout << y; } cout << s_end << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s1 = "I hate"; string s2 = "I love"; if (n == 1) { cout << "I hate it"; } else { for (int i = 0; i < n - 1; i++) { if (i % 2 == 0) { cout << s1 << " that "; } else { cout << s2 << " that "; } } if (n % 2 != 0) { cout << "I hate it"; } else { cout << "I love it"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; for (i = 1; i <= n; i++) if (i % 2 == 1) { cout << "I hate"; if (i < n) cout << " that "; } else { cout << "I love"; if (i < n) cout << " that "; } cout << " it"; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i; cin >> n; for (i = 1; i < n; i++) { if (i % 2 == 0) { cout << "I love that" << " "; } else { cout << "I hate that" << " "; } } if (n % 2 == 0) cout << "I love it" << " "; else cout << "I hate it" << " "; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; for (int i = 1; i < n; i++) cout << ((i % 2 == 0) ? "I love that " : "I hate that "); cout << (n % 2 == 0 ? "I love it" : "I hate it") << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string result = ""; for (int i = 1; i <= n; i++) { if (i > 1) result += " that "; if (i % 2 == 0) { result += "I love"; } else { result += "I hate"; } if (i == n) result += " it\n"; } cout << result; return 0; }
#include <bits/stdc++.h> using namespace std; long long ar[100010]; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); string s1 = "I hate that "; string s2 = "I love that "; string s3 = "I hate it "; string s4 = "I love it "; long long n, i; cin >> n; for (i = 1; i < n + 1; i++) { if (i != n) { if (i % 2 == 0) cout << s2; else cout << s1; } else { if (i % 2 == 0) cout << s4; else cout << s3; } } cout << "\n"; return 0; }
#include <bits/stdc++.h> int main() { int n, i = 1, f = 0, k = 0; scanf("%d", &n); while (i <= n) { if (i % 2 != 0) { printf("I hate "); f = 1; } if (f == 1 && i != n) { printf("that "); f = 0; } if (i % 2 == 0) { printf("I love "); k = 1; } if (k == 1 && i != n) { printf("that "); k = 0; } i++; } printf("it\n"); return 0; }