Submission #66726

#TimeUsernameProblemLanguageResultExecution timeMemory
66726MrTEKStove (JOI18_stove)C++14
100 / 100
44 ms1640 KiB
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define len(a) (int)a.size() #define fi first #define sc second #define d1(w) cerr<<#w<<":"<<w<<endl; #define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl; #define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl; #define left ind+ind #define right ind+ind+1 #define mid (l+r)/2 #define FAST_IO ios_base::sync_with_stdio(false); #define endl '\n' typedef long long int ll; const int maxn = 620; const long long LINF = 1e18; const int LOG = 31; const int INF = 1e9; const int N = 1e5 + 5; const int M = 1e4 + 5; const int SQ = 350; const int MOD = 998244353; typedef pair <int,int> pii; int n,k,t[N]; long long ans; vector <int> v; int main() { scanf("%d %d",&n,&k); k--; for (int i = 1 ; i <= n ; i++) scanf("%d",&t[i]); sort(t + 1 , t + n + 1); for (int i = 1 ; i < n ; i++) { v.pb(t[i + 1] - t[i]); } sort(v.begin(),v.end()); reverse(v.begin(),v.end()); for (int i = 0 ; i < k ; i++) ans += v[i]; printf("%lld\n",(t[n] - t[1] + 1) - ans + k); }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:39: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:43:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1 ; i <= n ; i++) scanf("%d",&t[i]);
                                 ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...