Submission #654098

# Submission time Handle Problem Language Result Execution time Memory
654098 2022-10-29T23:50:07 Z sofija6 Zalmoxis (BOI18_zalmoxis) C++14
50 / 100
882 ms 112076 KB
#include <bits/stdc++.h>
#define ll long long
#define MAXN 1000010
using namespace std;
map<ll,vector<ll> > m;
ll a[MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,k,x;
    cin >> n >> k;
    priority_queue<pair<ll,pair<ll,ll> >,vector<pair<ll,pair<ll,ll> > >,greater<pair<ll,pair<ll,ll> > > > q;
    for (ll i=1;i<=n;i++)
    {
        cin >> a[i];
        q.push({a[i],{i,i}});
    }
    while (true)
    {
        auto t=q.top();
        q.pop();
        if (q.empty())
        {
            x=t.first;
            break;
        }
        if (q.top().first!=t.first || q.top().second.first!=t.second.second+1)
        {
            m[t.second.second].push_back(t.first);
            t.first++;
            q.push(t);
            k--;
            continue;
        }
        t.second.second=q.top().second.second;
        q.pop();
        t.first++;
        q.push(t);
    }
    for (ll i=1;i<=n;i++)
    {
        cout << a[i] << " ";
        for (ll j=0;j<m[i].size();j++)
            cout << m[i][j] << " ";
    }
    if (x!=30)
    {
        priority_queue<ll> q;
        for (ll i=29;i>=x && k;i--)
        {
            k--;
            q.push(i);
        }
        while (k--)
        {
            ll t=q.top();
            q.pop();
            q.push(t-1);
            q.push(t-1);
        }
        while (!q.empty())
        {
            cout << q.top() << " ";
            q.pop();
        }
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:43:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (ll j=0;j<m[i].size();j++)
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 826 ms 111908 KB Output is correct
2 Correct 821 ms 111996 KB Output is correct
3 Correct 813 ms 112076 KB Output is correct
4 Correct 865 ms 111940 KB Output is correct
5 Correct 811 ms 111952 KB Output is correct
6 Correct 820 ms 111924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 882 ms 111872 KB Unexpected end of file - int32 expected
2 Correct 772 ms 111984 KB Output is correct
3 Incorrect 735 ms 111840 KB Unexpected end of file - int32 expected
4 Incorrect 825 ms 111940 KB Unexpected end of file - int32 expected
5 Incorrect 792 ms 112056 KB Unexpected end of file - int32 expected
6 Incorrect 774 ms 111948 KB Unexpected end of file - int32 expected
7 Incorrect 781 ms 112004 KB Unexpected end of file - int32 expected
8 Incorrect 808 ms 112008 KB Unexpected end of file - int32 expected
9 Incorrect 690 ms 93400 KB Unexpected end of file - int32 expected
10 Correct 366 ms 51144 KB Output is correct
11 Incorrect 438 ms 60128 KB Unexpected end of file - int32 expected
12 Correct 170 ms 11304 KB Output is correct
13 Correct 161 ms 11172 KB Output is correct
14 Incorrect 165 ms 11220 KB not a zalsequence