Submission #86462

# Submission time Handle Problem Language Result Execution time Memory
86462 2018-11-26T10:56:30 Z Pluton Hindeks (COCI17_hindeks) C++14
50 / 50
109 ms 2516 KB
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define sz size()
#define all(xx) xx.begin(),xx.end()
#define pb push_back
#define in insert
#define er erase
#define S second
#define F first
#define pii pair <int, int>
#define to_be continue
#define mp make_pair
#define stop exit (0)
#define fname ""
#define speed ios_base::sync_with_stdio(0);cin.tie(0)
#define input freopen (fname".in", "r", stdin)
#define output freopen (fname".out", "w", stdout)
//#define int ll
#define N 600000

using namespace std;

const int inf = 1e9 + 123;
const ll INF = 1e18 + 123;
const double pi = acos (-1.0);
const ld eps = 1e-3;

int n, a[N], ans, x = 1;

int main ()
{
	speed;
	cin >> n;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
	sort (a + 1, a + 1 + n);
	for (int i = 0; i <= a[n]; i ++)
	{                     
		if (i <= n - (x - 1))
			ans = i;
		while (a[x] == i)
			x ++;          
	}
	cout << ans;
}
//Coded by A....
# Verdict Execution time Memory Grader output
1 Correct 3 ms 388 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 2 ms 584 KB Output is correct
7 Correct 5 ms 584 KB Output is correct
8 Correct 27 ms 924 KB Output is correct
9 Correct 109 ms 2516 KB Output is correct
10 Correct 48 ms 2516 KB Output is correct