Submission #977288

# Submission time Handle Problem Language Result Execution time Memory
977288 2024-05-07T16:37:40 Z alexdd Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
1000 ms 188272 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
set<pair<int,int>> init;
set<pair<int,pair<int,int>>> s;
set<pair<pair<int,int>,int>> s2;
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    int a;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        int cv = 1000005LL*i;
        init.insert({cv,a});
        s.insert({a,{cv,cv}});
        s2.insert({{cv,cv},a});
    }
    while((int)s.size()>1 && k>=0)
    {
        pair<int,pair<int,int>> aux = *s.begin();
        int val = aux.first;
        int le = aux.second.first;
        int ri = aux.second.second;
        auto it = s2.lower_bound({{le,ri},val});
        if(next(it)!=s2.end() && (*next(it)).second==val)
        {
            int le2 = (*next(it)).first.first;
            int ri2 = (*next(it)).first.second;

            s.insert({val+1,{le,ri2}});
            s2.insert({{le,ri2},val+1});

            s.erase({val,{le2,ri2}});
            s2.erase({{le2,ri2},val});

            s.erase({val,{le,ri}});
            s2.erase({{le,ri},val});
        }
        else
        {
            k--;
            init.insert({ri+1,val});

            s.insert({val+1,{le,ri+1}});
            s2.insert({{le,ri+1},val+1});

            s.erase({val,{le,ri}});
            s2.erase({{le,ri},val});
        }
    }
    if(k>0)
    {
        int le = (*s.begin()).second.first;
        int ri = (*s.begin()).second.second;
        int val = (*s.begin()).first;
        if(k==1)
        {
            init.insert({ri+1,val});
        }
        else
        {

        }
    }
    for(auto x:init)
    {
        cout<<x.second<<" ";
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:56:13: warning: unused variable 'le' [-Wunused-variable]
   56 |         int le = (*s.begin()).second.first;
      |             ^~
# Verdict Execution time Memory Grader output
1 Execution timed out 1041 ms 188176 KB Time limit exceeded
2 Execution timed out 1078 ms 188232 KB Time limit exceeded
3 Execution timed out 1052 ms 188240 KB Time limit exceeded
4 Execution timed out 1049 ms 188228 KB Time limit exceeded
5 Execution timed out 1082 ms 188252 KB Time limit exceeded
6 Execution timed out 1077 ms 188244 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 188092 KB Time limit exceeded
2 Execution timed out 1071 ms 188104 KB Time limit exceeded
3 Execution timed out 1025 ms 187832 KB Time limit exceeded
4 Execution timed out 1018 ms 188160 KB Time limit exceeded
5 Execution timed out 1057 ms 188096 KB Time limit exceeded
6 Execution timed out 1079 ms 188272 KB Time limit exceeded
7 Execution timed out 1063 ms 188112 KB Time limit exceeded
8 Execution timed out 1063 ms 188240 KB Time limit exceeded
9 Execution timed out 1059 ms 150608 KB Time limit exceeded
10 Incorrect 603 ms 57536 KB Unexpected end of file - int32 expected
11 Execution timed out 1012 ms 95684 KB Time limit exceeded
12 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected