Submission #99146

#TimeUsernameProblemLanguageResultExecution timeMemory
99146rzbtStove (JOI18_stove)C++14
100 / 100
67 ms2420 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 typedef long long ll; using namespace std; int n,k; int niz[MAXN]; vector<int> razmaci; int main() { scanf("%d %d", &n, &k); for(int i=1;i<=n;i++) scanf("%d", niz+i); sort(niz+1,niz+1+n); for(int i=2;i<=n;i++){ razmaci.pb(niz[i]-niz[i-1]-1); } sort(all(razmaci),greater<int>()); int res=niz[n]-niz[1]+1; for(int i=0;i<k-1;i++)res-=razmaci[i]; printf("%d",res); return 0; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", niz+i);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...