Submission #770735

# Submission time Handle Problem Language Result Execution time Memory
770735 2023-07-01T20:20:15 Z emad234 medians (balkan11_medians) C++17
5 / 100
22 ms 3536 KB
#include <bits/stdc++.h>
#define all(v) ((v).bvin(),(v).end())
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
const ll mxN = 2e6 + 3;
bool vis[mxN];
int b[mxN];
int a[mxN];
int mx ,mn;
void pshmx(){
  while(vis[mx]){
    mx--;
  }
}void pshmn(){
  while(vis[mn]){
    mn++;
  }
}
signed main()
{
  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  int n;
  cin >>n;
  mx = 2 * n - 1;mn = 1;
  for(int i = 1;i <= n;i++) cin >> b[i];
  a[1] = b[1];
  vis[b[1]] = 1;
  pshmn();
  pshmx();
  for(int i = 2;i <= n;i++){
    int l = 2 * i - 2,r = 2 * i - 1;
    if(b[i - 1] < b[i]){
      a[l] = b[i];vis[a[l]] = 1;
      a[r] = mx;vis[mx] = 1;
      pshmx();
    }
    if(b[i - 1] > b[i]){
      a[l] = b[i];vis[a[l]] = 1;
      a[r] = mn;vis[mn] = 1;
      pshmn();
    }
    if(b[i - 1] == b[i]){
      a[l] = mn;vis[mn] = 1;
      a[r] = mx;vis[mx] = 1;
      pshmn();
      pshmx();
    }
  }
  for(int i = 1;i <= 2 * n - 1;i++){
    cout<<a[i]<<' ';
  }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Not a permutation
2 Incorrect 1 ms 340 KB Not a permutation
3 Incorrect 1 ms 340 KB Not a permutation
4 Incorrect 1 ms 340 KB Not a permutation
5 Incorrect 1 ms 328 KB Not a permutation
6 Correct 1 ms 340 KB Output is correct
7 Incorrect 0 ms 340 KB Not a permutation
8 Incorrect 1 ms 340 KB Not a permutation
9 Incorrect 1 ms 340 KB Not a permutation
10 Incorrect 1 ms 332 KB Not a permutation
11 Incorrect 1 ms 340 KB Not a permutation
12 Incorrect 1 ms 340 KB Not a permutation
13 Incorrect 1 ms 340 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Not a permutation
2 Incorrect 1 ms 340 KB Not a permutation
3 Incorrect 2 ms 468 KB Not a permutation
4 Incorrect 3 ms 852 KB Not a permutation
5 Incorrect 6 ms 1240 KB Not a permutation
6 Incorrect 12 ms 2308 KB Not a permutation
7 Incorrect 22 ms 3536 KB Not a permutation