Submission #14094

# Submission time Handle Problem Language Result Execution time Memory
14094 2015-05-01T13:38:42 Z exqt 이상한 수열 (OJUZ10_bizarre) C++
100 / 100
27 ms 2112 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;

#define in cin
#define out cout
#define _abs(a) ((a)>0?(a):(-(a)))
#define _min(a,b) ((a)>(b)?(b):(a))
#define _max(a,b) ((a)<(b)?(b):(a))
#define isin(a,b,c) ((a)<=(c)&&(c)<=(b))
#define REP(i,e) for(int i=0; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=e; i>=s; i--)

int main()
{
    int n;
    in >> n;
    vector<int> v(n);
    REP(i,n) in >> v[i];
    int m; in >> m;

    if(m <= n)
    {
        out << v[m-1] << endl;
        return 0;
    }

    //
    vector<int> vv(n);
    REP(i,n) vv[i] = v[i];
    sort(vv.begin(), vv.end());

    //
    int cnt = 1;
    REP(i,n-1) {
        if(vv[i] != vv[i+1]) cnt++;
    }

    //
    int tt = lower_bound(vv.begin(), vv.end(), cnt)-vv.begin();
    if(tt != n)
    {
        tt = vv[tt];

        m -= (n+1);
        if(tt-cnt > m)
            out << cnt + m;
        else
            out << tt;
    }
    else
    {
        out << cnt+(m-n)-1 << endl;
    }


    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
6 Correct 0 ms 1720 KB Output is correct
7 Correct 0 ms 1720 KB Output is correct
8 Correct 0 ms 1720 KB Output is correct
9 Correct 0 ms 1720 KB Output is correct
10 Correct 0 ms 1720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1916 KB Output is correct
2 Correct 6 ms 1720 KB Output is correct
3 Correct 9 ms 1920 KB Output is correct
4 Correct 23 ms 1916 KB Output is correct
5 Correct 4 ms 1720 KB Output is correct
6 Correct 9 ms 2040 KB Output is correct
7 Correct 4 ms 1720 KB Output is correct
8 Correct 18 ms 2112 KB Output is correct
9 Correct 23 ms 1916 KB Output is correct
10 Correct 7 ms 2024 KB Output is correct
11 Correct 26 ms 2112 KB Output is correct
12 Correct 0 ms 1720 KB Output is correct
13 Correct 15 ms 2112 KB Output is correct
14 Correct 19 ms 1916 KB Output is correct
15 Correct 15 ms 1908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 2112 KB Output is correct
2 Correct 8 ms 1920 KB Output is correct
3 Correct 11 ms 2040 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 21 ms 2112 KB Output is correct
6 Correct 25 ms 2112 KB Output is correct
7 Correct 22 ms 2112 KB Output is correct
8 Correct 18 ms 2096 KB Output is correct
9 Correct 21 ms 2112 KB Output is correct
10 Correct 27 ms 2112 KB Output is correct
11 Correct 18 ms 2112 KB Output is correct
12 Correct 6 ms 1720 KB Output is correct
13 Correct 2 ms 1720 KB Output is correct
14 Correct 14 ms 2024 KB Output is correct
15 Correct 0 ms 1720 KB Output is correct