Submission #702374

# Submission time Handle Problem Language Result Execution time Memory
702374 2023-02-23T19:32:12 Z m_fenais Stove (JOI18_stove) C++17
100 / 100
53 ms 3176 KB
#include <bits/stdc++.h>
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int N = 100000 + 10, mod = 1e9 + 7;
int n, k, a[N], ans;
vector<int> v;
signed main() {
	cin >> n >> k;
	ans += n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	for(int i = 1; i < n; i++) if(a[i] - a[i-1] > 1) v.push_back(a[i] - a[i-1] - 1);
	sort(v.begin(), v.end());
	k--;
	if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i];
	cout << ans << endl;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:17:7: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i];
      |     ~~^~~~~~~~~~
stove.cpp:17:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   17 |  if(k < v.size()) for(int i = 0; i < v.size() - k; i++) ans += v[i];
      |                                  ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 324 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 324 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 324 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 53 ms 3100 KB Output is correct
17 Correct 50 ms 3176 KB Output is correct
18 Correct 46 ms 3132 KB Output is correct
19 Correct 46 ms 3124 KB Output is correct
20 Correct 45 ms 3092 KB Output is correct
21 Correct 45 ms 3108 KB Output is correct
22 Correct 49 ms 3140 KB Output is correct
23 Correct 44 ms 3116 KB Output is correct
24 Correct 44 ms 3120 KB Output is correct