Submission #30717

# Submission time Handle Problem Language Result Execution time Memory
30717 2017-07-26T08:35:46 Z okaybody10 이상한 수열 (OJUZ10_bizarre) C++
76 / 100
19 ms 4080 KB
#include <stdio.h>
#include <vector>
#define MAXN 1000000
using namespace std;
bool check[2000001];
int main()
{
    // M이 S보다 작을때까지는 수열은 S의 수열을 따를것이므로 bool check해서 그걸 기록해놓는다.
    // 그 외의 경우에는, 즉 M이 S보다 큰 경우에는 S+1번째 항 부터 다른 것의 횟수 cnt, cnt+1, ... 이걸 bool형에 check해나가면서 ++한다.
    // 만약 한번이라도 bool[now]가 있다면, 그건 무조건적으로 cnt에 멈추게 된다.
    // for돌면서 하면 된다.
    // Si 최대 범위가 -100만에서 100만이므로, 걍 수를 받아들이면 +100한 수가 존재하는지 본다. bool형이므로 노상관 ㅋ
    int N,maxval=1e9-1,diff=0;
    scanf("%d",&N);
    vector<int> S(N);
    for(int i=0;i<N;i++)
    {
        scanf("%d",&S[i]);
        if(!check[S[i]+MAXN])
            diff++;
        check[S[i]+MAXN]=true;
    }
    int M;
    scanf("%d",&M);
    for(int i=MAXN;i<=2*MAXN;i++)
    {
        if(check[i] && diff<(i-MAXN))
        {
            maxval=i-MAXN;
            break;
        }
    }
    if(M<=N)
        printf("%d",S[M-1]);
    else if(maxval>M)
        printf("%d",M-(N+1)+diff);
    else
        printf("%d",maxval);
}

Compilation message

bizarre.cpp: In function 'int main()':
bizarre.cpp:14:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
                   ^
bizarre.cpp:18:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&S[i]);
                          ^
bizarre.cpp:24:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&M);
                   ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3884 KB Output is correct
2 Correct 0 ms 3884 KB Output is correct
3 Correct 0 ms 3884 KB Output is correct
4 Correct 0 ms 3884 KB Output is correct
5 Correct 0 ms 3884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3884 KB Output is correct
2 Incorrect 0 ms 3884 KB Output isn't correct
3 Correct 0 ms 3884 KB Output is correct
4 Correct 0 ms 3884 KB Output is correct
5 Halted 0 ms 0 KB -
6 Correct 0 ms 3884 KB Output is correct
7 Correct 0 ms 3884 KB Output is correct
8 Correct 0 ms 3884 KB Output is correct
9 Correct 0 ms 3884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3884 KB Output is correct
2 Correct 13 ms 4080 KB Output is correct
3 Correct 0 ms 3884 KB Output is correct
4 Correct 0 ms 3884 KB Output is correct
5 Correct 6 ms 4080 KB Output is correct
6 Correct 3 ms 4036 KB Output is correct
7 Correct 3 ms 4060 KB Output is correct
8 Correct 0 ms 4016 KB Output is correct
9 Correct 6 ms 4080 KB Output is correct
10 Correct 3 ms 4044 KB Output is correct
11 Correct 6 ms 4072 KB Output is correct
12 Correct 6 ms 4080 KB Output is correct
13 Correct 9 ms 4080 KB Output is correct
14 Correct 6 ms 4080 KB Output is correct
15 Correct 6 ms 4080 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4060 KB Output is correct
2 Correct 9 ms 4080 KB Output is correct
3 Correct 9 ms 4080 KB Output is correct
4 Correct 6 ms 4072 KB Output is correct
5 Correct 9 ms 4080 KB Output is correct
6 Correct 0 ms 3884 KB Output is correct
7 Correct 3 ms 4044 KB Output is correct
8 Correct 3 ms 4080 KB Output is correct
9 Correct 3 ms 4036 KB Output is correct
10 Correct 3 ms 4016 KB Output is correct
11 Correct 0 ms 3884 KB Output is correct
12 Correct 3 ms 3884 KB Output is correct
13 Correct 13 ms 4080 KB Output is correct
14 Correct 19 ms 4080 KB Output is correct
15 Correct 9 ms 4080 KB Output is correct