Submission #64084760


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
// -----------------------------------------------------macros------------------------------------------------------------------
#define int long long int
#define vi vector<int>
#define pb push_back
#define in(a, b, arr) for(int i = a; i < b; i++){cin>>arr[i];}
#define out(a, b, arr) for(int i = a; i < b; i++){cout<<arr[i]<<' ';}cout<<endl;
//------------------------------------------------------ constants ------------------------------------------------------------
int mod=1e9+7;
// ------------------------------------------------------basic functions----------------------------------------------------------------
void primeSieve(vector<int> &sieve, int N)
{
// mark 1 and 0 as not prime
sieve[1] = sieve[0] = 0;
// start from 2 and mark all multiples of ith number(prime) as not prime
for (int i = 2; i <= N ; i++)
{
int p = sieve[i];
if (p==1)
{
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
// -----------------------------------------------------macros------------------------------------------------------------------
#define int long long int
#define vi vector<int>
#define pb push_back
#define in(a, b, arr) for(int i = a; i < b; i++){cin>>arr[i];}
#define out(a, b, arr) for(int i = a; i < b; i++){cout<<arr[i]<<' ';}cout<<endl;
//------------------------------------------------------ constants ------------------------------------------------------------
int mod=1e9+7;
// ------------------------------------------------------basic functions----------------------------------------------------------------
void primeSieve(vector<int> &sieve, int N)
{
    // mark 1 and 0 as not prime
    sieve[1] = sieve[0] = 0;
    // start from 2 and mark all multiples of ith number(prime) as not prime
    for (int i = 2; i <= N ; i++)
    {
            int p = sieve[i];
            if (p==1)
            {
                for (int j = i*i; j <= N; j = j+i)
                {
                    // marking j as not prime
                    sieve[j] = 0;
                }
            }
    }
}
int power(int a,int b)
{
    a%=mod;
    int res=1;
    while(b>0)
    {
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res%mod;

}
vector<int> primeFactors(int n)
{
    vector<int> v;
    // Print the number of 2s that divide n 
    while (n % 2 == 0)
    {
        v.push_back(2);
        n = n/2;
    }
    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n 
        while (n % i == 0)
        {
            v.push_back(i);
            n = n/i;
        }
    }
    // This condition is to handle the case when n
    // is a prime number greater than 2 
    if (n > 2) 
        v.push_back(n);
    return v;

}
vector<int> printDivisors(int n) 
{
    vector<int> v;
    // Note that this loop runs till square root
    for (int i=1; i<=sqrt(n); i++)
    {
        if (n%i == 0)
        {
            // If divisors are equal, print only one
            if (n/i == i)
                v.push_back(i);
            else{ // Otherwise print both
                v.push_back(i);
                v.push_back(n/i);
            }
        }
    }
    return v;
}
// -------------------------------------------------------advanced functions-----------------------------------------------------
int add(int x, int y)
{
    return (x%mod + y%mod)%mod;

}
int subtract(int x, int y)
{
    return (x%mod - y%mod + mod)%mod;

}
int multiply(int x, int y)
{
    return ((x%mod)*(y%mod))%mod;

}
int divide(int x, int y)
{
    return multiply(x, power(y, mod-2));

}
int factorial(int n)
{
    int fact[n+1];
    fact[0]=1;
    for (int i = 1; i <=n; i++)
    {
        fact[i] = multiply(fact[i-1], i);
    }
    return fact[n];

}
int inverse(int x)
{
    return power(x, mod-2);

}
int nCr(int n, int r)
{
    return multiply(factorial(n), multiply(inverse(factorial(r)), inverse(factorial(n-r))));
}
//------------------------------------------------------------------main function---------------------------------------
int32_t main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
       int n;
       cin>>n;
       map<int, int> m1,m2;
       for (int i = 0; i < n; i++)
       {
            int a;
            cin>>a;
            m1[a]++;
            m2[a]=i;
       }
       int ans=-1;
       for(auto x : m1){
        if(x.second==1){
            ans=max(ans, x.first);
        }
       }
       if(ans==-1) cout<<ans<<endl;
       else cout<<m2[ans]+1<<endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - Uniqueness
User isha_406
Language C++ 20 (gcc 12.2)
Score 300
Code Size 3865 Byte
Status AC
Exec Time 364 ms
Memory 41068 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, hand_02.txt, hand_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3404 KB
hand_02.txt AC 1 ms 3504 KB
hand_03.txt AC 1 ms 3636 KB
random_01.txt AC 357 ms 41068 KB
random_02.txt AC 102 ms 18280 KB
random_03.txt AC 306 ms 39460 KB
random_04.txt AC 204 ms 30216 KB
random_05.txt AC 364 ms 40408 KB
random_06.txt AC 224 ms 15908 KB
random_07.txt AC 163 ms 12772 KB
random_08.txt AC 162 ms 13008 KB
random_09.txt AC 73 ms 3444 KB
random_10.txt AC 159 ms 22192 KB
random_11.txt AC 158 ms 22192 KB
random_12.txt AC 169 ms 22160 KB
random_13.txt AC 170 ms 22188 KB
random_14.txt AC 185 ms 22264 KB
random_15.txt AC 185 ms 22264 KB
random_16.txt AC 62 ms 10204 KB
random_17.txt AC 10 ms 4728 KB
random_18.txt AC 164 ms 19132 KB
random_19.txt AC 125 ms 15664 KB
random_20.txt AC 92 ms 12616 KB
random_21.txt AC 2 ms 3696 KB
random_22.txt AC 132 ms 15700 KB
random_23.txt AC 51 ms 8940 KB
sample_01.txt AC 1 ms 3472 KB
sample_02.txt AC 1 ms 3628 KB


2025-04-03 (Thu)
18:53:26 +00:00