Submission #155370

# Submission time Handle Problem Language Result Execution time Memory
155370 2019-09-27T16:52:11 Z Charis02 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
865 ms 101128 KB
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 300004
#define INF 1e9+7

using namespace std;

ll n,k,ar[N],orig[N];
set < pi > s;
ll epomeno[N],proigoumeno[N];
vector < pi > res;
multiset < pi > varta;
multiset < pi > answers;

void solve()
{
    if((*s.begin()).first == 30)
        return;

    set < pi >::iterator it = s.begin();
    pi cur = *it;
    swap(cur.first,cur.second);

   // cout << cur.first << " " << cur.second << endl;

    if(epomeno[cur.first] != n && ar[epomeno[cur.first]] == cur.second)
    {
        epomeno[cur.first] = epomeno[epomeno[cur.first]];
        s.erase(s.begin());
    }
    else
    {
        res.push_back(mp(cur.second,cur.first));
    }

    s.erase(s.begin());
    s.insert(mp(cur.second+1,cur.first));
    ar[cur.first]++;

    solve();

    return;
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;

    rep(i,0,n)
    {
        cin >> ar[i];
        orig[i] = ar[i];
        epomeno[i] = i+1;
        proigoumeno[i+1] = i;
        s.insert(mp(ar[i],i));
    }

    solve();

    rep(i,0,res.size())
        varta.insert(res[i]);

    ll cur = 0;
    ll sz = res.size();

    res.clear();

    while(sz < k)
    {
        pi f = *varta.begin();
        varta.erase(varta.begin());
        if(f.first == 0)
        {
            swap(f.first,f.second);
            answers.insert(f);
            continue;
        }

        f.first--;
        varta.insert(f);
        varta.insert(f);
        sz++;
    }

    for(set < pi >::iterator it = varta.begin();it != varta.end();it++)
    {
        pi neo;
        neo.first = it->second;
        neo.second = it->first;
        answers.insert(neo);
    }

    res.clear();

    for(set < pi >::iterator it = answers.begin();it != answers.end();it++)
    {
        res.push_back(*it);
    }

    rep(i,0,n)
    {
        while(cur < k && res[cur].first <= i)
        {
            cout << res[cur].second << " ";
            cur++;
        }

        cout << orig[i] << " ";
    }

    cout << endl;

    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:13:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define rep(i,a,b) for(int i = a;i < b;i++)
zalmoxis.cpp:73:9:
     rep(i,0,res.size())
         ~~~~~~~~~~~~~~              
zalmoxis.cpp:73:5: note: in expansion of macro 'rep'
     rep(i,0,res.size())
     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 236 ms 47480 KB Unexpected end of file - int32 expected
2 Incorrect 275 ms 47744 KB Unexpected end of file - int32 expected
3 Incorrect 236 ms 47592 KB Unexpected end of file - int32 expected
4 Incorrect 234 ms 47608 KB Unexpected end of file - int32 expected
5 Incorrect 252 ms 47596 KB Unexpected end of file - int32 expected
6 Incorrect 239 ms 47576 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 238 ms 47664 KB Unexpected end of file - int32 expected
2 Incorrect 227 ms 47632 KB Unexpected end of file - int32 expected
3 Incorrect 241 ms 47568 KB Unexpected end of file - int32 expected
4 Incorrect 245 ms 47488 KB Unexpected end of file - int32 expected
5 Incorrect 241 ms 47608 KB Unexpected end of file - int32 expected
6 Incorrect 239 ms 47524 KB Unexpected end of file - int32 expected
7 Incorrect 242 ms 47692 KB Unexpected end of file - int32 expected
8 Incorrect 240 ms 47608 KB Unexpected end of file - int32 expected
9 Incorrect 273 ms 51564 KB Unexpected end of file - int32 expected
10 Incorrect 865 ms 101128 KB not a zalsequence
11 Incorrect 401 ms 55272 KB Unexpected end of file - int32 expected
12 Incorrect 675 ms 80956 KB not a zalsequence
13 Incorrect 625 ms 80908 KB not a zalsequence
14 Incorrect 588 ms 80820 KB not a zalsequence