This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vcll;
typedef vector<int> vci;
typedef pair<ll, ll> prll;
typedef pair<int, int> prii;
#define f0r(i, a, n) for (i = a; i < (n); i++)
#define f1r(i, a, n) for (i = a; i <= (n); i++)
#define r0f(i, n, a) for (i = n; i > (a); i--)
#define r1f(i, n, a) for (i = n; i >= (a); i--)
#define pb push_back
#define all(item) item.begin(), item.end()
#define mxN 100'010
ll n, m;
vcll diff_ar;
inline void take_input()
{
scanf("%lli %lli", &n, &m);
ll last;
scanf("%lli", &last);
n--;
ll i;
f0r(i, 0, n)
{
ll t;
// printf("i: %lli, n: %lli\n", i, n);
scanf("%lli", &t);
last++;
// printf("t: %lli, last: %lli\n", t, last);
diff_ar.pb(t - last);
// printf("put value on %lli : %lli\n", i, t - last);
last = t;
}
// sort(all(diff_ar));
sort(diff_ar.begin(), diff_ar.end());
// for (auto const &v : diff_ar) printf("v: %lli\n", v);
}
inline void give_output()
{
ll i;
ll sum = 0;
n++;
// printf("n - m: %lli\n", n - m);
// printf("diff_ar[0]: %lli\n", diff_ar[0]);
f0r(i, 0, n - m)
sum += diff_ar[i];
// printf("sum: %lli\n", sum);
printf("%lli\n", sum + n);
}
int main()
{
take_input();
give_output();
return 0;
}
Compilation message (stderr)
stove.cpp: In function 'void take_input()':
stove.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%lli %lli", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
stove.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | scanf("%lli", &last);
| ~~~~~^~~~~~~~~~~~~~~
stove.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%lli", &t);
| ~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |