Submission #52349

#TimeUsernameProblemLanguageResultExecution timeMemory
52349tmwilliamlin168Stove (JOI18_stove)C++14
100 / 100
16 ms1020 KiB
#include <bits/stdc++.h> using namespace std; inline int in() { int result = 0; char ch = getchar_unlocked(); while(true) { if(ch >= '0' && ch <= '9') break; ch = getchar_unlocked(); } result = ch-'0'; while(true) { ch = getchar_unlocked(); if (ch < '0' || ch > '9') break; result = result*10 + (ch - '0'); } return result; } inline void out(int x) { int rev=x, c=0; while(!(rev%10)) { ++c; rev/=10; } rev=0; while(x) { rev=rev*10+x%10; x/=10; } while(rev) { putchar_unlocked(rev%10+'0'); rev/=10; } while(c--) putchar_unlocked('0'); } const int mxN=1e5; int n, k, t1, t2, ans, d[mxN-1]; int main() { n=in(), k=in(); for(int i=0; i<n; ++i) { t2=in(); if(i) d[i-1]=t2-t1-1; t1=t2; } ans=n; sort(d, d+n-1); for(int i=0; i<n-k; ++i) ans+=d[i]; out(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...