Submission #122486

#TimeUsernameProblemLanguageResultExecution timeMemory
122486egorlifarStove (JOI18_stove)C++17
100 / 100
22 ms2428 KiB
/* ЗАПУСКАЕМ ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░ ▄███▀░◐░░░▌░░░░░░░ ░░░░▌░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▐░░░░░▐░░░░░░░ ░░░░▌░░░░░▐▄▄░░░░░ ░░░░▌░░░░▄▀▒▒▀▀▀▀▄ ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄ ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄ ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░░░▌▌░▌▌░░░░░ ░░░░░░░░░▄▄▌▌▄▌▌░░░░░ */ #include <iostream> #include <complex> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #include <cassert> #include <queue> #include <stack> #include <deque> #include <random> #include <chrono> using namespace std; template<class T1, class T2> inline int chkmin(T1 &x, const T2 &y) { if (x > y) { x = y; return 1; } else { return 0; } } template<class T1, class T2> inline int chkmax(T1 &x, const T2 &y) { if (x < y) { x = y; return 1; } else { return 0; } } #define all(c) (c).begin(), (c).end() #define sz(c) (int)(c).size() #define mp make_pair #define pb push_back #define read(FILENAME) freopen((string(FILENAME) + ".in").c_str(), "r", stdin) #define write(FILENAME) freopen((string(FILENAME) + ".out").c_str(), "w", stdout); template<class iterator> void output(iterator begin, iterator end, ostream &out = cerr) { while (begin != end) { out << (*begin) << " "; begin++; } out << endl; } template<class T> void output(const T &x, ostream &out = cerr) { output(x.begin(), x.end(), out); } void fast_io() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } const int MAXN = 100228; int n, k; int t[MAXN]; int main() { fast_io(); //read("input"); cin >> n >> k; vector<int> st; for (int i = 0; i < n; i++) { cin >> t[i]; if (i) { st.pb(t[i] - t[i - 1] - 1); } } int ans = t[n - 1] - t[0] + 1; sort(all(st)); reverse(all(st)); for (int i = 0; i < min(sz(st), k - 1); i++) { ans -= st[i]; } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...