답안 #431181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431181 2021-06-17T10:09:39 Z Abdulmohsen1284 Zalmoxis (BOI18_zalmoxis) C++14
30 / 100
235 ms 47272 KB
//#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
long long a[2000005];
vector <long long> plc[1000006];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n,k;
    cin>>n>>k;
    vector < pair <long long, long long> > v;
    vector <long long> ans;
    v.push_back({-1,0});
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        long long cur=a[i],m=a[i];
        bool ad=false;
        //cout<<"bruh"<<endl;
        //if(v.size()>0){
        while(cur==v[v.size()-1].first)
        {
            v.pop_back();
            cur++;
            ad=true;
            m=cur;
            if(v.size()==0)
                break;
        }
            v.push_back({m,i});
    }
    if(v.size()==2)
    {
        for(int i=0;i<n;i++)
        {
            cout<<a[i]<<" ";
        }
        for(int i=0;i<k;i++)
        {
            cout<<v[1].first+i<<" ";
        }
        return 0;
    }
    sort(v.begin(),v.end());
    //plc[v[1].second].push_back(v[1].first);
    for(int j=v[1].first;j<v[2].first;j++)
            {
                plc[v[1].second].push_back(j);
            }
    for(int i=3;i<v.size();i++)
    {
        if(v[i].first>v[i-1].first+1)
        {
            for(int j=v[i-1].first;j<v[i].first;j++)
            {
                plc[v[i-1].second].push_back(j);
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        ans.push_back(a[i]);
        for(int j=0;j<plc[i].size();j++)
            ans.push_back(plc[i][j]);
    }
    long long ma=0;

    for(int i=0;i<v.size();i++)
    {
        ma=max(ma,v[i].first);
    }
    for(int i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }
    for(int i=0;i<(n+k)-ans.size();i++)
    {
        cout<<ma+i+1<<" ";
    }
    return 0;
}

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:20:14: warning: variable 'ad' set but not used [-Wunused-but-set-variable]
   20 |         bool ad=false;
      |              ^~
zalmoxis.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=3;i<v.size();i++)
      |                 ~^~~~~~~~~
zalmoxis.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int j=0;j<plc[i].size();j++)
      |                     ~^~~~~~~~~~~~~~
zalmoxis.cpp:70:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
zalmoxis.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |     for(int i=0;i<ans.size();i++)
      |                 ~^~~~~~~~~~~
zalmoxis.cpp:78:18: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
   78 |     for(int i=0;i<(n+k)-ans.size();i++)
      |                 ~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 41652 KB Output is correct
2 Correct 201 ms 41688 KB Output is correct
3 Correct 192 ms 41584 KB Output is correct
4 Correct 190 ms 41764 KB Output is correct
5 Correct 197 ms 41644 KB Output is correct
6 Correct 195 ms 41644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 191 ms 41576 KB not a zalsequence
2 Incorrect 235 ms 41860 KB not a zalsequence
3 Incorrect 196 ms 42064 KB not a zalsequence
4 Incorrect 193 ms 41632 KB not a zalsequence
5 Incorrect 197 ms 41612 KB not a zalsequence
6 Incorrect 190 ms 41608 KB not a zalsequence
7 Incorrect 193 ms 41676 KB not a zalsequence
8 Incorrect 197 ms 41632 KB not a zalsequence
9 Incorrect 220 ms 47272 KB not a zalsequence
10 Incorrect 197 ms 37140 KB not a zalsequence
11 Incorrect 183 ms 44448 KB not a zalsequence
12 Incorrect 109 ms 30640 KB not a zalsequence
13 Incorrect 114 ms 30636 KB not a zalsequence
14 Incorrect 112 ms 30660 KB not a zalsequence