Submission #55899

#TimeUsernameProblemLanguageResultExecution timeMemory
55899YaDon4ickStove (JOI18_stove)C++14
100 / 100
45 ms1656 KiB
//By Don4ick //#define _GLIBCXX_DEBUG #include <bits/stdc++.h> typedef long long ll; typedef long double ld; typedef unsigned int ui; #define forn(i, n) for (int i = 1; i <= n; i++) #define pb push_back #define all(x) x.begin(), x.end() #define y1 qwer1234 const double PI = acos(-1.0); const int DIR = 4; const int X[] = {1, 0, -1, 0}; const int Y[] = {0, 1, 0, -1}; using namespace std; int main() { //ios_base::sync_with_stdio(false); //cin.tie(NULL); //cout.tie(NULL); //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); int n, k; scanf("%d%d", &n, &k); vector < int > a(n); for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(all(a)); vector < int > b; for (int i = 1; i < n; i++) b.pb(a[i] - a[i - 1] - 1); sort(all(b)); 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 main()':
stove.cpp:32: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:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...