답안 #61888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
61888 2018-07-27T04:26:53 Z alex(#2140) Zalmoxis (BOI18_zalmoxis) C++11
20 / 100
1000 ms 94700 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>

using namespace std;

struct node
{
    int x;
    list<pair<bool, int>> l;
};

list<node> a;

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);

    int n, k, i;
    scanf("%d%d", &n, &k);
    for(i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        a.push_back({ x, list<pair<bool, int>>(1, {true, x}) });
    }

    int c = 0;
    for(i = 0; i < 30; i++)
    {
        for(auto it = a.begin(); it != a.end(); it++)
        {
            if(it->x != i)
                continue;

            auto it2 = next(it);
            if(it2 != a.end() && it2->x == i)
            {
                it->l.splice(it->l.end(), it2->l);
                a.erase(it2);
            }
            else
            {
                c++;
                it->l.push_back({ false, it->x });
            }

            it->x++;
        }
    }
    assert(a.size() == 1);

    int x = a.front().x;
    auto r = a.front().l;

    for(i = x; i < 30; i++)
    {
        c++;
        r.push_back({ false, i });
    }

    for(auto it = r.begin(); it != r.end(); it++)
    {
        while(it->first != true && it->second != 0 && c < k)
        {
            c++;
            it->second--;
            r.insert(next(it), { false, it->second });
        }
    }

    for(auto it = r.begin(); it != r.end(); it++)
        printf("%d ", it->second);
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~
zalmoxis.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 94412 KB Time limit exceeded
2 Execution timed out 1077 ms 94416 KB Time limit exceeded
3 Execution timed out 1086 ms 94564 KB Time limit exceeded
4 Execution timed out 1062 ms 94564 KB Time limit exceeded
5 Execution timed out 1076 ms 94564 KB Time limit exceeded
6 Execution timed out 1088 ms 94564 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 94564 KB Time limit exceeded
2 Execution timed out 1022 ms 94596 KB Time limit exceeded
3 Execution timed out 1074 ms 94596 KB Time limit exceeded
4 Execution timed out 1066 ms 94596 KB Time limit exceeded
5 Execution timed out 1087 ms 94596 KB Time limit exceeded
6 Execution timed out 1066 ms 94596 KB Time limit exceeded
7 Execution timed out 1055 ms 94672 KB Time limit exceeded
8 Execution timed out 1057 ms 94700 KB Time limit exceeded
9 Execution timed out 1060 ms 94700 KB Time limit exceeded
10 Correct 833 ms 94700 KB Output is correct
11 Execution timed out 1087 ms 94700 KB Time limit exceeded
12 Correct 249 ms 94700 KB Output is correct
13 Correct 234 ms 94700 KB Output is correct
14 Correct 238 ms 94700 KB Output is correct