Submission #238637

# Submission time Handle Problem Language Result Execution time Memory
238637 2020-06-12T08:35:35 Z Vimmer Karte (COCI18_karte) C++14
120 / 120
143 ms 7800 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 500001
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 2> a2;

//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


bool mk[N], mkr[N];

int mt[N], pr[N];

int main()
{
    //freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m;

    cin >> n >> m;

    vector <int> g(n);

    for (int i = 0; i < n; i++) cin >> g[i];

    sort(g.begin(), g.end());

    int r = 0, l = 0;

    for (int i = 0; i < n; i++) {mt[i] = r; if (r < g[i]) {mk[i] = 1; r++;} }

    reverse(g.begin(), g.end());

    for (int i = 0; i < n; i++) if (l < g[i]) l++;

    if (r < m || l > m) {cout << -1 << endl; exit(0);}

    sort(g.begin() + m, g.end());

    sort(g.begin(), g.begin() + m);

    reverse(g.begin(), g.end());


    for (auto it : g) cout << it << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1784 KB Output is correct
2 Correct 23 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3192 KB Output is correct
2 Correct 39 ms 3320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 7416 KB Output is correct
2 Correct 93 ms 7800 KB Output is correct