Submission #636408

# Submission time Handle Problem Language Result Execution time Memory
636408 2022-08-29T08:16:07 Z berr Hindeks (COCI17_hindeks) C++17
50 / 50
74 ms 4180 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n; cin>>n;
    vector<int> a(n); 

    for(int i=0; i<n; i++) cin>>a[i];

    int h=0;
    


    int s=0;

    sort(a.begin(), a.end(), greater<int>());

    for(int i=0; i<n; i++)
    {
        a[i]*=-1;
    }



    for(int i=31; i>=0; i--)
    {
        int tmp=s+(1LL<<i);
        tmp*=-1;
        int pos=upper_bound(a.begin(), a.end(), tmp)-a.begin()+1;
        pos--;
        tmp*=-1;

        if(pos>=tmp) s=tmp;
    }

    cout<<s;
}

Compilation message

hindeks.cpp: In function 'int32_t main()':
hindeks.cpp:13:9: warning: unused variable 'h' [-Wunused-variable]
   13 |     int h=0;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 14 ms 1108 KB Output is correct
9 Correct 74 ms 4180 KB Output is correct
10 Correct 37 ms 2260 KB Output is correct