Submission #81705

# Submission time Handle Problem Language Result Execution time Memory
81705 2018-10-26T09:09:20 Z luckyboy Karte (COCI18_karte) C++14
12 / 120
116 ms 6936 KB
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 500005
#define maxm 500005
#define pii pair <int,int>
#define Task "Karte"
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,k,a[maxn << 1],cnt;
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    read(n),read(k);
    FOR(i,1,n) read(a[i]);
    sort(a+1,a+n+1);
    FOR(i,1,n) a[i+n] = a[i];
    FOR(i,1,n) if (cnt < a[i]) ++cnt;
    FOR(i,1,n - 1)
    {
        if (cnt == k)
        {
            FORD(j,n-1,0) write(a[i+j]);
            return 0;
        }
        --cnt;
        cnt += a[i] > cnt;
    }
    write(-1);
//    FOR(i,1,n) a[i+n] = a[i];
//    FOR(i,1,n)
//    {
//        if (Calc(i) == k)
//        {
//            FORD(j,n-1,0) write(a[i+j]);
//            return 0;
//        }
//    }
//    write(-1);
//    FOR(i,1,n)
//    {
//        if (a[i] == cnt) ++x[cnt].S;
//        else x[++cnt] = mp(a[i],1);
//    }
//    if (cnt < k)
//    {
//        write(-1);
//        return 0;
//    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1912 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 3208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 6936 KB Output isn't correct
2 Halted 0 ms 0 KB -