Submission #654093

# Submission time Handle Problem Language Result Execution time Memory
654093 2022-10-29T23:15:07 Z sofija6 Zalmoxis (BOI18_zalmoxis) C++14
35 / 100
866 ms 112120 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] << " ";
    }
    while (k--)
    {
        cout << x << " ";
        x++;
    }
    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 786 ms 111988 KB Output is correct
2 Correct 822 ms 111884 KB Output is correct
3 Correct 781 ms 111968 KB Output is correct
4 Correct 809 ms 112012 KB Output is correct
5 Correct 823 ms 111964 KB Output is correct
6 Correct 809 ms 111884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 845 ms 111960 KB not a zalsequence
2 Correct 750 ms 111856 KB Output is correct
3 Incorrect 747 ms 111828 KB not a zalsequence
4 Incorrect 864 ms 112032 KB not a zalsequence
5 Incorrect 830 ms 112040 KB not a zalsequence
6 Incorrect 866 ms 111892 KB not a zalsequence
7 Incorrect 839 ms 111960 KB not a zalsequence
8 Incorrect 797 ms 112120 KB not a zalsequence
9 Incorrect 699 ms 93776 KB not a zalsequence
10 Incorrect 324 ms 40768 KB not a zalsequence
11 Incorrect 484 ms 62396 KB not a zalsequence
12 Incorrect 69 ms 7232 KB not a zalsequence
13 Incorrect 61 ms 7232 KB not a zalsequence
14 Incorrect 69 ms 7124 KB not a zalsequence