제출 #503590

#제출 시각아이디문제언어결과실행 시간메모리
503590the_horoStove (JOI18_stove)C++17
100 / 100
55 ms1076 KiB
#include <algorithm> #include <cassert> #include <iostream> #include <vector> int main () { int n, k; std::cin >> n >> k; std::vector<int> t(n); for (int &val: t) std::cin >> val; std::vector<int> helper(n - 1); for (size_t i = 0; i != helper.size(); ++ i) helper[i] = t[i + 1] - t[i]; std::sort(helper.begin(), helper.end(), std::greater<int>{}); unsigned int total_operation = t.back() - t.front() + 1; assert(static_cast<size_t>(k) - 1 <= helper.size()); for (int i = 0; i < k - 1; ++ i) total_operation -= helper[i] - 1; std::cout << total_operation << std::endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...