답안 #668166

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
668166 2022-12-03T06:54:53 Z birthdaycake Zalmoxis (BOI18_zalmoxis) C++17
0 / 100
17 ms 4268 KB
//
//  main.cpp
//  u.cpp
//
//  Created by Juri Aljohani on 30/11/2022.
//
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#define int long long
#define endl '\n'
using namespace std;


int a[200001];
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,k, p = 0, cur = 0, mn = INT_MAX, j = 0; cin >> n >> k;
    deque<int>ans;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(a[i] == a[i - 1]) p = i;
        if(a[i] < mn){
            mn = a[i];
            j = i;
        }
    }
    int l = p - 2, r = p + 1;
    if(p == 0){
        cur = mn;
        ans.push_back(mn);
        ans.push_back(mn);
        l = j - 1; r = j + 1;
    }else{
        cur = a[p];
        ans.push_back(a[p]);
        ans.push_back(a[p]);
    }
    
    while(l >= 0 or r <= n){
        int x = cur + 1, y = cur + 2, fa = 0, fb = 0, ff = 0;
        if(a[l] == x){
            ans.push_front(x);
            l--;
            fa = 1;
            ff = 1;
        }else if(a[l] == y){
            ans.push_front(y);
            l--;
            fb = 1;
            ff = 1;
        }
        if(a[r] == x){
            ans.push_back(x);
            r++;
            fa = 1;
        }else if(a[r] == y){
            ans.push_back(y);
            r++;
            fb = 1;
        }
        if(fb + fa == 0) break;
        if(!fa){
            if((int)ans.size() + 1 > n + k) break;
            if(!ff) ans.push_front(x);
            else ans.push_back(x);
        }
        if(!fb){
            if((int)ans.size() + 1 > n + k) break;
            if(!ff) ans.push_front(y);
            else ans.push_back(y);
        }
        cur += 2;
    }
    for(int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
    return 0;
}
/*
 
 
 */

Compilation message

zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:159:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  159 |     for(int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 4180 KB Execution killed with signal 11
2 Runtime error 17 ms 4176 KB Execution killed with signal 11
3 Runtime error 12 ms 4180 KB Execution killed with signal 11
4 Runtime error 12 ms 4268 KB Execution killed with signal 11
5 Runtime error 11 ms 4224 KB Execution killed with signal 11
6 Runtime error 12 ms 4184 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 4144 KB Execution killed with signal 11
2 Runtime error 11 ms 4204 KB Execution killed with signal 11
3 Runtime error 11 ms 4184 KB Execution killed with signal 11
4 Runtime error 11 ms 4148 KB Execution killed with signal 11
5 Runtime error 14 ms 4180 KB Execution killed with signal 11
6 Runtime error 12 ms 4236 KB Execution killed with signal 11
7 Runtime error 11 ms 4180 KB Execution killed with signal 11
8 Runtime error 14 ms 4152 KB Execution killed with signal 11
9 Runtime error 13 ms 4172 KB Execution killed with signal 11
10 Runtime error 11 ms 4180 KB Execution killed with signal 11
11 Runtime error 12 ms 4180 KB Execution killed with signal 11
12 Incorrect 1 ms 212 KB Unexpected end of file - int32 expected
13 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected
14 Incorrect 0 ms 212 KB Unexpected end of file - int32 expected