Submission #155367

# Submission time Handle Problem Language Result Execution time Memory
155367 2019-09-27T16:41:17 Z Charis02 Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
360 ms 59040 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;

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.first,cur.second));
    }

    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();

    ll cur = 0;

    rep(i,0,n)
    {
        while(cur < res.size()&&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:75:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(cur < res.size()&&res[cur].first <= i)
               ~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 47352 KB Unexpected end of file - int32 expected
2 Incorrect 227 ms 47500 KB Unexpected end of file - int32 expected
3 Incorrect 232 ms 47352 KB Unexpected end of file - int32 expected
4 Incorrect 232 ms 47432 KB Unexpected end of file - int32 expected
5 Incorrect 225 ms 47352 KB Unexpected end of file - int32 expected
6 Incorrect 228 ms 47352 KB Unexpected end of file - int32 expected
# Verdict Execution time Memory Grader output
1 Incorrect 232 ms 47228 KB Unexpected end of file - int32 expected
2 Incorrect 229 ms 47416 KB Unexpected end of file - int32 expected
3 Incorrect 224 ms 47480 KB Unexpected end of file - int32 expected
4 Incorrect 227 ms 47352 KB Unexpected end of file - int32 expected
5 Incorrect 222 ms 47432 KB Unexpected end of file - int32 expected
6 Incorrect 222 ms 47324 KB Unexpected end of file - int32 expected
7 Incorrect 226 ms 47392 KB Unexpected end of file - int32 expected
8 Incorrect 248 ms 47244 KB Unexpected end of file - int32 expected
9 Incorrect 239 ms 51436 KB Unexpected end of file - int32 expected
10 Incorrect 360 ms 59040 KB Unexpected end of file - int32 expected
11 Incorrect 254 ms 55052 KB Unexpected end of file - int32 expected
12 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
13 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected
14 Incorrect 2 ms 376 KB Unexpected end of file - int32 expected