Submission #1017215

# Submission time Handle Problem Language Result Execution time Memory
1017215 2024-07-09T06:41:30 Z vjudge1 Stove (JOI18_stove) C++17
0 / 100
0 ms 344 KB
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define nemeshay ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define allr(pon) pon.rbegin(), pon.rend()
#define all(pon) pon.begin(), pon.end()
#define nosolve cout << "-1\n"
#define YES cout << "YES\n"
#define Yes cout << "Yes\n"
#define pii pair <int, int>
#define OK cout << "OK\n"
#define Ok cout << "Ok\n"
#define NO cout << "NO\n"
#define No cout << "No\n"
#define pf push_front
#define int long long
#define pb push_back
#define sigma signed
#define sc second
#define fr first
using namespace __gnu_pbds;
using namespace std;
const int N = 1e6 + 20, INF = 1e10 + 7;
int a[N], pref[N];
sigma main(){
    nemeshay
    int n, k, ans, mx = -1;
    cin >> n >> k;
    if (k == n) {
        cout << n * 2;
        return 0;
    }
    vector <int> pon;
    for (int i = 0; i < n; i++) cin >> a[i];
    ans = a[n - 1] + 2 - a[0];
    if (k == 1) {
        cout << ans;
        return 0;
    }
    for (int i = 1; i < n; i++) pon.pb(a[i] - a[i - 1] - 1);
    sort (pon.rbegin(), pon.rend());
    cout << ans << endl;
    for (int i = 0; i < k; i++) {
        ans -= pon[i];
        cout << pon[i] << ' ';
    }
    cout << ans;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:28:20: warning: unused variable 'mx' [-Wunused-variable]
   28 |     int n, k, ans, mx = -1;
      |                    ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -