Submission #368443

# Submission time Handle Problem Language Result Execution time Memory
368443 2021-02-20T04:27:18 Z cpp219 medians (balkan11_medians) C++14
5 / 100
58 ms 19564 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fs first
#define sc second
using namespace std;
const ll N = 2e3 + 9;
const ll inf = 1e16 + 7;
typedef pair<int,int> LL;
vector<ll> ans;
set<ll> s;
ll n,b[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "tst"
    if (fopen(task".INP","r")){
        freopen(task".INP","r",stdin);
        //freopen(task".OUT","w",stdout);
    }
    cin>>n;
    for (ll i = 1;i <= 2*n - 1;i++) s.insert(i);
    for (ll i = 1;i <= n;i++) cin>>b[i],s.erase(b[i]);
    ans.push_back(b[1]);
    for (ll i = 2;i <= n;i++){
        if (b[i] != b[i - 1]) ans.push_back(b[i]);
        if (b[i - 1] >= b[i]) ans.push_back(*s.begin()),s.erase(s.begin());
        if (b[i - 1] <= b[i]) ans.push_back(*prev(s.end())),s.erase(prev(s.end()));
    }
    for (auto i : ans) cout<<i<<" ";
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Not a permutation
2 Incorrect 1 ms 364 KB Not a permutation
3 Incorrect 1 ms 364 KB Not a permutation
4 Incorrect 1 ms 364 KB Not a permutation
5 Incorrect 1 ms 364 KB Not a permutation
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Not a permutation
8 Incorrect 1 ms 364 KB Not a permutation
9 Incorrect 1 ms 364 KB Not a permutation
10 Incorrect 1 ms 364 KB Not a permutation
11 Incorrect 1 ms 364 KB Not a permutation
12 Incorrect 1 ms 396 KB Not a permutation
13 Incorrect 1 ms 492 KB Not a permutation
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 620 KB Not a permutation
2 Runtime error 3 ms 1260 KB Execution killed with signal 11
3 Runtime error 5 ms 2028 KB Execution killed with signal 11
4 Runtime error 11 ms 3564 KB Execution killed with signal 11
5 Runtime error 17 ms 6764 KB Execution killed with signal 11
6 Runtime error 36 ms 12780 KB Execution killed with signal 11
7 Runtime error 58 ms 19564 KB Execution killed with signal 11