Submission #55899

# Submission time Handle Problem Language Result Execution time Memory
55899 2018-07-09T07:11:43 Z YaDon4ick Stove (JOI18_stove) C++14
100 / 100
45 ms 1656 KB
//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

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 time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 3 ms 716 KB Output is correct
15 Correct 3 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 544 KB Output is correct
5 Correct 2 ms 544 KB Output is correct
6 Correct 2 ms 544 KB Output is correct
7 Correct 2 ms 544 KB Output is correct
8 Correct 3 ms 560 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 3 ms 588 KB Output is correct
11 Correct 3 ms 588 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 3 ms 716 KB Output is correct
15 Correct 3 ms 716 KB Output is correct
16 Correct 32 ms 1624 KB Output is correct
17 Correct 33 ms 1624 KB Output is correct
18 Correct 34 ms 1624 KB Output is correct
19 Correct 32 ms 1624 KB Output is correct
20 Correct 40 ms 1624 KB Output is correct
21 Correct 39 ms 1624 KB Output is correct
22 Correct 30 ms 1656 KB Output is correct
23 Correct 34 ms 1656 KB Output is correct
24 Correct 45 ms 1656 KB Output is correct