Submission #372446

# Submission time Handle Problem Language Result Execution time Memory
372446 2021-02-28T08:17:04 Z Killer2501 medians (balkan11_medians) C++14
5 / 100
94 ms 12268 KB
#include <bits/stdc++.h>
#define pb push_back
#define vii vector<int>
#define task "media"
#define pll pair<ll, ll>
#define pii pair< pll, ll >
#define fi first
#define se second

using namespace std;
using ll = long long ;
using ull = unsigned long long;
const int N = 3e5+5;
const ll mod = 1e9+7;
const ll base1 = 1313;
const ll base2 = 3113;
ll m, n, k, t, T, ans, a[N], b[N], c[N], lab[N], tong, cur;
vector<ll> kq;
set<ll> st;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}

void sol()
{
    cin >> n;
    for(int i = 1; i <= n; i ++)cin >> b[i];
    kq.pb(b[1]);
    for(int i = 1; i <= n*2-1; i ++)st.insert(i);
    st.erase(b[1]);
    for(int i = 2; i <= n; i ++)
    {
        if(st.find(b[i]) != st.end())
        {
            kq.pb(b[i]);
            st.erase(b[i]);
            if(b[i] > b[i-1])
            {
                kq.pb(*st.rbegin());
                st.erase(*st.rbegin());
            }
            else
            {
                kq.pb(*st.begin());
                st.erase(*st.begin());
            }
        }
        else
        {
            if(b[i] == b[i-1])
            {
                kq.pb(*st.begin());
                st.erase(*st.begin());
                kq.pb(*st.rbegin());
                st.erase(*st.rbegin());
            }
            else if(b[i] < b[i-1])
            {
                kq.pb(*st.begin());
                st.erase(*st.begin());
            }
            else
            {
                kq.pb(*st.rbegin());
                st.erase(*st.rbegin());
            }
        }
    }
    for(ll x : kq)cout << x <<" ";
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".in", "r"))
    {
		freopen(task".in","r",stdin);
		freopen(task".out","w",stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    for(int tt = 1; tt <= ntest; tt ++)
    sol();
}

Compilation message

medians.cpp: In function 'int main()':
medians.cpp:85:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   85 |   freopen(task".in","r",stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
medians.cpp:86:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   86 |   freopen(task".out","w",stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
2 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
3 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
4 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
5 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
6 Correct 1 ms 364 KB Output is correct
7 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
8 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
9 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
10 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
11 Incorrect 1 ms 364 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 364 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 492 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 620 KB Unexpected end of file - int32 expected
2 Incorrect 3 ms 876 KB Unexpected end of file - int32 expected
3 Incorrect 7 ms 1388 KB Unexpected end of file - int32 expected
4 Incorrect 15 ms 2284 KB Unexpected end of file - int32 expected
5 Incorrect 28 ms 4076 KB Unexpected end of file - int32 expected
6 Incorrect 58 ms 7916 KB Unexpected end of file - int32 expected
7 Incorrect 94 ms 12268 KB Unexpected end of file - int32 expected