답안 #373740

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373740 2021-03-05T14:44:22 Z vishesh312 Karte (COCI18_karte) C++17
0 / 120
79 ms 4456 KB
#include "bits/stdc++.h"
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
*/

#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()

using ll = long long;
const int mod = 1e9+7;

void solve(int tc) {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (auto &x : v) cin >> x;
    sort(all(v));
    vector<int> ans;
    for (int i = 0; i < n-k; ++i) {
        ans.push_back(v[i]);
        if (v[i] > k) {
            cout << "-1\n";
            return;
        }
    }
    for (int i = n-1; i >= 0; --i) {
        ans.push_back(v[i]);
        if (v[i] <= n-1-i) {
            cout << "-1\n";
            return;
        }
    }
  reverse(all(ans));
    for (int x : ans) cout << x << " "; cout << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int tc = 1;
    //cin >> tc;
    for (int i = 1; i <= tc; ++i) solve(i);
    return 0;
}

Compilation message

karte.cpp: In function 'void solve(int)':
karte.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for (int x : ans) cout << x << " "; cout << '\n';
      |     ^~~
karte.cpp:37:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   37 |     for (int x : ans) cout << x << " "; cout << '\n';
      |                                         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 19 ms 1392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 2412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 79 ms 4456 KB Output isn't correct
2 Halted 0 ms 0 KB -