답안 #1108717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108717 2024-11-04T20:33:29 Z vicvic Zalmoxis (BOI18_zalmoxis) C++11
45 / 100
158 ms 14664 KB
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;
ifstream f ("zalmoxis.in");
ofstream g ("zalmoxis.out");
int n, k, v[2000005], poz, added[2000005], s[2000005], cnt;
void descp (int j)
{
    if (j<=1)
    {
        cout << j << " ";
    }
    else if (k>0)
    {
        k--;
        descp (j-1);
        descp (j-1);
    }
    else cout << j << " ";
}
int main()
{
    cin >> n >> k;
    int poz=0, adaugate=0;
    for (int i=1; i<=n; i++)
    {
        int x;
        cin >> x;
        while (cnt && s[cnt]<x)
        {
            v[++poz]=s[cnt];
            k--;
            int val=v[poz];
            while (cnt && val==s[cnt])
            {
                cnt--;
                val++;
            }
            s[++cnt]=val;
            added[poz]=1;
        }
        v[++poz]=x;
        while (cnt && x==s[cnt])
        {
            cnt--;
            x++;
        }
        s[++cnt]=x;
    }
    while (s[1]<30)
    {
        k--;
        v[++poz]=s[cnt];
        added[poz]=1;
        int val=v[poz];
        while (cnt && s[cnt]==val)
        {
            cnt--;
            val++;
        }
        s[++cnt]=val;
    }
    assert (k>=0);
    for (int i=1; i<=poz; i++)
    {
        if (added[poz])
        {
            descp (v[i]);
        }
        else cout << v[i] << " ";
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:25:16: warning: unused variable 'adaugate' [-Wunused-variable]
   25 |     int poz=0, adaugate=0;
      |                ^~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 10692 KB Output is correct
2 Correct 153 ms 10568 KB Output is correct
3 Correct 155 ms 10568 KB Output is correct
4 Correct 154 ms 10584 KB Output is correct
5 Correct 151 ms 10688 KB Output is correct
6 Correct 151 ms 10568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 158 ms 12620 KB doesn't contain S as a subsequence
2 Correct 147 ms 14664 KB Output is correct
3 Incorrect 142 ms 14664 KB Unexpected end of file - int32 expected
4 Correct 147 ms 12736 KB Output is correct
5 Incorrect 154 ms 14664 KB doesn't contain S as a subsequence
6 Incorrect 142 ms 12616 KB doesn't contain S as a subsequence
7 Incorrect 158 ms 12616 KB doesn't contain S as a subsequence
8 Incorrect 158 ms 12752 KB doesn't contain S as a subsequence
9 Incorrect 129 ms 14664 KB doesn't contain S as a subsequence
10 Incorrect 81 ms 10568 KB doesn't contain S as a subsequence
11 Incorrect 109 ms 10568 KB doesn't contain S as a subsequence
12 Incorrect 55 ms 6472 KB doesn't contain S as a subsequence
13 Incorrect 58 ms 6352 KB doesn't contain S as a subsequence
14 Correct 53 ms 6476 KB Output is correct