Submission #41599

#TimeUsernameProblemLanguageResultExecution timeMemory
41599AbelyanStove (JOI18_stove)C++14
100 / 100
35 ms1516 KiB
#define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> using namespace std; #define mpr make_pair #define pr pair<int,long long> #define st string #define vint vector<int> #define vpr vector<pr> #define fr first #define sc second #define add push_back #define del pop_back #define qdel pop inline int scn() { int hg; scanf("%d",&hg); return hg; }; const int N=100006; int a[N],b[N]; int main(){ ios_base::sync_with_stdio(false); int n=scn(); int k=scn(); for (int i=0;i<n;i++){ a[i]=scn(); if (i>0){ b[i-1]=a[i]-a[i-1]-1; } } sort(b,b+n-1); int ans=n; for (int i=0;i<n-k;i++){ ans+=b[i]; } cout<<ans<<endl; return 0; }

Compilation message (stderr)

stove.cpp: In function 'int scn()':
stove.cpp:15:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 inline int scn() { int hg; scanf("%d",&hg); return hg; };
                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...