답안 #750133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750133 2023-05-29T07:05:45 Z mohammedMonem Zalmoxis (BOI18_zalmoxis) C++14
0 / 100
3 ms 720 KB
#include <bits/stdc++.h>

void Run();

int main() {
    Run();
    int n, k;
    std::cin >> n >> k;
    std::vector<int> s(n);
    for (auto &i: s) {
        std::cin >> i;
    }
    std::pair<int, int> cur = {std::min_element(s.begin(), s.end()) - s.begin(),
                               std::min_element(s.begin(), s.end()) - s.begin()};
    int curI = *std::min_element(s.begin(), s.end());
    std::deque<int> ans = {curI};
    while (curI < 30) {
        if (cur.second < n - 1 && s[cur.second + 1] == curI) {
            ans.push_back(curI);
            cur.second++, curI++;
        }
        else if (cur.first > 0 && s[cur.first - 1] == curI){
            ans.push_front(curI);
            cur.first--, curI++;
        }
        else {
            ans.push_back(curI);
            curI++;
        }
    }
    for (const auto &i: ans) {
        std::cout << i << ' ';
    }
}

void Run() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie();
    std::cout.tie();
#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
#endif
}

Compilation message

zalmoxis.cpp: In function 'void Run()':
zalmoxis.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen("input.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
zalmoxis.cpp:42:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         freopen("output.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 468 KB Execution killed with signal 11
2 Runtime error 3 ms 468 KB Execution killed with signal 11
3 Runtime error 3 ms 596 KB Execution killed with signal 11
4 Runtime error 3 ms 468 KB Execution killed with signal 11
5 Runtime error 3 ms 468 KB Execution killed with signal 11
6 Runtime error 2 ms 524 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 516 KB Execution killed with signal 11
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Runtime error 3 ms 468 KB Execution killed with signal 11
4 Runtime error 3 ms 596 KB Execution killed with signal 11
5 Runtime error 2 ms 720 KB Execution killed with signal 11
6 Runtime error 3 ms 468 KB Execution killed with signal 11
7 Runtime error 2 ms 596 KB Execution killed with signal 11
8 Runtime error 2 ms 468 KB Execution killed with signal 11
9 Runtime error 3 ms 596 KB Execution killed with signal 11
10 Runtime error 2 ms 468 KB Execution killed with signal 11
11 Runtime error 2 ms 468 KB Execution killed with signal 11
12 Runtime error 2 ms 596 KB Execution killed with signal 11
13 Runtime error 2 ms 596 KB Execution killed with signal 11
14 Runtime error 3 ms 468 KB Execution killed with signal 11