Submission #373742

# Submission time Handle Problem Language Result Execution time Memory
373742 2021-03-05T14:47:50 Z vishesh312 Karte (COCI18_karte) C++17
12 / 120
83 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 >= n-k; --i) {
        ans.push_back(v[i]);
        if (v[i] <= n-1-i) {
            cout << "-1\n";
            return;
        }
    }
    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:36:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   36 |     for (int x : ans) cout << x << " "; cout << '\n';
      |     ^~~
karte.cpp:36:41: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   36 |     for (int x : ans) cout << x << " "; cout << '\n';
      |                                         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 2412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 4456 KB Output isn't correct
2 Halted 0 ms 0 KB -