Submission #24800

# Submission time Handle Problem Language Result Execution time Memory
24800 2017-06-14T04:40:20 Z rondojim medians (balkan11_medians) C++14
5 / 100
36 ms 3460 KB
#include <stdio.h>

const int MAXN = 2e5 + 5;

int vis[MAXN], minimum, maximum, A[MAXN], B[MAXN], N;

void plus(){ while(vis[minimum]) minimum++; }
void minus(){ while(vis[maximum]) maximum--; }

int main(){
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif
  scanf("%d", &N);
  for(int i=1; i<=N; ++i) scanf("%d", &B[i]);
  minimum = 0, maximum = 2 * N;
  vis[minimum] = vis[maximum] = vis[B[1]] = A[1] = 1;
  for(int i=2; i<=N; ++i){
    if(B[i - 1] == B[i]){
      plus(); A[2 * i - 2] = minimum, vis[minimum] = 1;
      minus(); A[2 * i - 1] = maximum, vis[maximum] = 1;
    }
    else if(B[i - 1] < B[i]){
      if(!vis[B[i]]){
        A[2 * i - 2] = B[i], vis[B[i]] = 1;
        minus(); A[2 * i - 1] = maximum, vis[maximum] = 1;
      }
      else{
        minus(); A[2 * i - 2] = maximum, vis[maximum] = 1;
        minus(); A[2 * i - 1] = maximum, vis[maximum] = 1;
      }
    }
    else if(B[i - 1] > B[i]){
      if(!vis[B[i]]){
        A[2 * i - 2] = B[i], vis[B[i]] = 1;
        plus(); A[2 * i - 1] = minimum, vis[minimum] = 1;
      }
      else{
        plus(); A[2 * i - 2] = minimum, vis[minimum] = 1;
        plus(); A[2 * i - 1] = minimum, vis[minimum] = 1;
      }
    }
  }
  for(int i=1; i<2*N; ++i) printf("%d ", A[i]);
  puts("");
  return 0;
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:14:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &N);
                  ^
medians.cpp:15:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   for(int i=1; i<=N; ++i) scanf("%d", &B[i]);
                                             ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3460 KB Not a permutation
2 Incorrect 0 ms 3460 KB Not a permutation
3 Correct 0 ms 3460 KB Output is correct
4 Incorrect 0 ms 3460 KB Not a permutation
5 Incorrect 0 ms 3460 KB Not a permutation
6 Incorrect 0 ms 3460 KB Not a permutation
7 Incorrect 0 ms 3460 KB Not a permutation
8 Incorrect 0 ms 3460 KB Not a permutation
9 Incorrect 0 ms 3460 KB Not a permutation
10 Incorrect 0 ms 3460 KB Not a permutation
11 Incorrect 0 ms 3460 KB Not a permutation
12 Incorrect 0 ms 3460 KB Not a permutation
13 Incorrect 0 ms 3460 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 3460 KB Not a permutation
2 Incorrect 0 ms 3460 KB Not a permutation
3 Incorrect 0 ms 3460 KB Not a permutation
4 Incorrect 6 ms 3460 KB Not a permutation
5 Incorrect 16 ms 3460 KB Not a permutation
6 Incorrect 16 ms 3460 KB Not a permutation
7 Incorrect 36 ms 3460 KB Not a permutation