# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
268997 |
2020-08-17T04:38:48 Z |
zipdang04 |
Stove (JOI18_stove) |
C++14 |
|
23 ms |
1792 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
// struct Node
// {
// int node, len;
// Node() {node = len = 0;}
// Node(int node, int len) {this -> node = node, this -> len = len;}
// };
// typedef vector<Node> vg;
#define MAX 1000001
#define MOD 1000000007
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define FOR(type, i, a, b) for(type i = (a); i <= (b); i++)
#define FORR(type, i, b, a) for(type i = (b); i >= (a); i--)
#define testBit(n, bit) ((n >> bit) & 1)
#define flipBit(n, bit) (n ^ (1ll << bit))
#define cntBit(n) __builtin_popcount(n)
#define cntBitll(n) __builtin_popcountll(n)
#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n, k; cin >> n >> k;
int a[n + 1];
int mi = INT32_MAX, ma = INT32_MIN;
FOR(int, i, 1, n){
cin >> a[i];
mi = min(mi, a[i]); ma = max(ma, a[i]);
}
int total = ma - mi + 1;
FOR(int, i, 1, n)
a[i] = a[i + 1] - a[i] - 1;
// FOR(int, i, 1, n - 1) cerr << a[i] << '|'; cerr << '\n';
sort(a + 1, a + n, greater<int>());
FOR(int, i, 1, k - 1) total -= a[i];
cout << total;
}
Compilation message
stove.cpp:40:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
40 | main()
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
20 ms |
1664 KB |
Output is correct |
17 |
Correct |
20 ms |
1664 KB |
Output is correct |
18 |
Correct |
23 ms |
1664 KB |
Output is correct |
19 |
Correct |
20 ms |
1664 KB |
Output is correct |
20 |
Correct |
20 ms |
1664 KB |
Output is correct |
21 |
Correct |
21 ms |
1664 KB |
Output is correct |
22 |
Correct |
23 ms |
1664 KB |
Output is correct |
23 |
Correct |
22 ms |
1664 KB |
Output is correct |
24 |
Correct |
20 ms |
1792 KB |
Output is correct |