Submission #856060

# Submission time Handle Problem Language Result Execution time Memory
856060 2023-10-02T16:09:25 Z vjudge1 Hindeks (COCI17_hindeks) C++17
50 / 50
36 ms 8196 KB
#ifndef Local
    #pragma GCC optimize("O3,unroll-loops")
    #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define lim 1000001
using namespace std;
const int mod=1000000007ll;

void solve(){
    int n;
    cin>>n;
    int a[lim];
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
        int tem;
        cin>>tem;
        a[tem]++;
    }
    int cur=0;
    for(int i=1e6;0<=i;i--){
        cur+=a[i];
        if(i<=cur){
            cout<<i;
            return;
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
#ifdef Local  
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 8024 KB Output is correct
2 Correct 4 ms 8028 KB Output is correct
3 Correct 4 ms 8028 KB Output is correct
4 Correct 4 ms 8084 KB Output is correct
5 Correct 4 ms 8028 KB Output is correct
6 Correct 4 ms 8028 KB Output is correct
7 Correct 5 ms 8196 KB Output is correct
8 Correct 10 ms 8028 KB Output is correct
9 Correct 36 ms 8028 KB Output is correct
10 Correct 19 ms 8024 KB Output is correct