Submission #636408

#TimeUsernameProblemLanguageResultExecution timeMemory
636408berrHindeks (COCI17_hindeks)C++17
50 / 50
74 ms4180 KiB
#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 (stderr)

hindeks.cpp: In function 'int32_t main()':
hindeks.cpp:13:9: warning: unused variable 'h' [-Wunused-variable]
   13 |     int h=0;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...