제출 #1317074

#제출 시각아이디문제언어결과실행 시간메모리
1317074udargabiStove (JOI18_stove)C++20
100 / 100
14 ms1204 KiB
#include <bits/stdc++.h> using namespace std; #define USE_STD_IO 1 #if USE_STD_IO #define fin cin #define fout cout #else ifstream fin("txt.in"); ofstream fout("txt.out"); #endif int n, k, i, t[100002], dif[100002], rasp; int main() { if(USE_STD_IO) ios_base::sync_with_stdio(false); fin.tie(NULL); fout.tie(NULL); fin >> n >> k; for(i = 1; i <= n; i++) fin >> t[i]; rasp = t[n] - t[1] + 1; for(i = 2; i <= n; i++) { dif[i - 1] = t[i] - t[i - 1] - 1; } sort(dif + 1, dif + n, greater<int>()); fout << rasp - accumulate(dif + 1, dif + k, 0LL); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...