Submission #19724335
Source Code Expand
Copy
// Author:- Pratik Kinger
// Birla Institute of Technology
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define f(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define FIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define mod 1000000007
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
const ll MOD = 1000000000 + 7;
ll powermod(ll a, ll b, ll modi)
{
a %= modi;
ll res = 1;
while (b)
{
if (b % 2)
{
res = (res * a) % modi;
}
b /= 2;
a = (a * a) % modi;
}
return res;
}
ll power(ll a, ll b)
{
ll res = 1;
while (b > 0)
{
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
ll binarySearch(ll a[], ll low, ll high, ll key)
{
while (low <= high)
{
ll mid = (low + high) / 2;
if (a[mid] < key)
{
low = mid + 1;
}
else if (a[mid] > key)
{
high = mid - 1;
}
else
{
return mid;
}
}
return -1;
}
ll gcd(ll a, ll b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
return (a / gcd(a, b)) * b;
}
ll binarytodecimal(string n)
{
string num = n;
ll dec_value = 0;
ll base = 1;
ll len = num.length();
for (int i = len - 1; i >= 0; i--)
{
if (num[i] == '1')
dec_value += base;
base = base * 2;
}
return dec_value;
}
string dtb(ll n)
{
string s = "";
while (n > 0)
{
if (n % 2 == 0)
s.pb('0');
else
s.pb('1');
n /= 2;
}
reverse(all(s));
return s;
}
vi seive;
void Seive()
{
const ll maxn = 1e6 + 5;
seive.resize(maxn);
f(i, 0, maxn) seive[i] = i;
for (ll i = 2; i <= maxn; i += 2)
seive[i] = 2;
seive[1] = -1;
seive[0] = -1;
for (ll i = 3; i <= maxn; i += 2)
if (i == seive[i])
for (ll j = i * i; j < maxn; j += i)
if (seive[j] == j)
seive[j] = i;
}
//------------------------------CODE--HERE--------------------------
//----------global--variables-------------------
//------------end-------------------------------
void solve()
{
ll n;
cin>>n;
ll k = pow(2,n);
ll ar[k];
vector<ll> v;
f(i,0,k)
{
cin>>ar[i];
v.pb(ar[i]);
}
for(int i = 0; i<n-1 ;i++)
{
k = k/2;
for(int j = 0; j<k; j++)
{
v[j] = max(v[2*j], v[2*j + 1]);
}
}
ll x = min(v[0], v[1]);
for(int i = 0; i<pow(2,n); i++)
{
if(ar[i] == x)
{
cout<<(i+1)<<"\n";
break;
}
}
}
//------------------------------
int main()
{
//FAST INPUT OUTPUT
FIO;
//INPUT OUTPUT
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t = 1;
while (t--)
{
solve();
}
return 0;
}
Submission Info
Submission Time |
|
Task |
C - ABC Tournament |
User |
its_me_pratik |
Language |
C++ (GCC 9.2.1) |
Score |
300 |
Code Size |
3624 Byte |
Status |
AC |
Exec Time |
18 ms |
Memory |
4668 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample_01.txt, sample_02.txt, sample_03.txt |
All |
extreme_00.txt, handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, sample_01.txt, sample_02.txt, sample_03.txt |
Case Name |
Status |
Exec Time |
Memory |
extreme_00.txt |
AC |
13 ms |
4624 KB |
handmade_00.txt |
AC |
2 ms |
3612 KB |
handmade_01.txt |
AC |
2 ms |
3536 KB |
random_00.txt |
AC |
18 ms |
4648 KB |
random_01.txt |
AC |
17 ms |
4616 KB |
random_02.txt |
AC |
14 ms |
4668 KB |
random_03.txt |
AC |
2 ms |
3920 KB |
random_04.txt |
AC |
3 ms |
3980 KB |
random_05.txt |
AC |
2 ms |
3964 KB |
sample_01.txt |
AC |
2 ms |
3660 KB |
sample_02.txt |
AC |
2 ms |
3784 KB |
sample_03.txt |
AC |
2 ms |
3952 KB |