Submission #127205

#TimeUsernameProblemLanguageResultExecution timeMemory
127205MrUnknownStove (JOI18_stove)C++11
100 / 100
28 ms2292 KiB
/*** * __ __ _ _ _ * | \/ | | | | | | | * | \ / |_ __ | | | |_ __ | | ___ __ _____ ___ __ * | |\/| | '__| | | | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \ * | | | | | _ | |__| | | | | <| | | | (_) \ V V /| | | | * |_| |_|_| (_) \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_| * * */ #include<stdio.h> #include<bits/stdc++.h> using namespace std; #define ll long long #define f(i,a,b) for (int i=a;i<=b;i++) #define f_(i,a,b) for (int i=a;i>=b;i--) #define ii pair<int,int> #define iii pair<int,ii> #define MP make_pair int n,a[100005],k,ans; vector<int> v; int main() { // freopen("","r",stdin); // freopen("","w",stdout); scanf("%d %d", &n, &k); f(i,1,n) scanf("%d", &a[i]); if (k>=n) printf("%d", n); else { ans=n; f(i,2,n) v.push_back(a[i]-a[i-1]-1); sort(v.begin(),v.end()); f(i,1,n-k) ans+=v[i-1]; printf("%d", ans); } return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:27:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  f(i,1,n) scanf("%d", &a[i]);
           ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...