# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1049730 |
2024-08-09T04:30:59 Z |
vjudge1 |
Stove (JOI18_stove) |
C++17 |
|
11 ms |
2352 KB |
/*
author: CRISTIANO RONALDO
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
can do: find_by_order, order_of_key
__builtin_clz(x): the number of zeros at the beginning of the number
__builtin_ctz(x): the number of zeros at the end of the number
__builtin_popcount(x): the number of ones in the number
__builtin_parity(x): the parity (even or odd) of the number of ones
mt19937 rng(16);
mt19937 bruh(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rofl(chrono::steady_clock::now().time_since_epoch().count());
*/
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define lv v+v
#define rv v+v+1
#define files freopen("aa.txt", "r", stdin), freopen("aa.txt", "w", stdout)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pll = pair <long long, long long>;
using pii = pair <int,int>;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
long long mod = 998244353;
const ll N = 1e5 + 10;
const ll M = 7e3 + 10;
const ll P = 311;
const ld EPS = 1e-7;
const ll block = 450;
const ll inf = 2e18;
ll n,k,a[N],ans=inf;
bool bit(ll num, ll pos) {
return ((num >> pos) & 1);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>k;
for(ll i = 1; i<=n; i++) {
cin>>a[i];
}
vector <ll> v;
for(ll i = 2; i<=n; i++) {
v.pb(a[i] - a[i-1]);
}
sort(all(v));
ans = k;
for(ll i = 0; i<v.size() && i < n-k; i++) {
ans += v[i];
}
cout<<ans;
return 0;
}
// equal, min, max, 1, random, build
/*
*/
Compilation message
stove.cpp: In function 'int main()':
stove.cpp:61:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(ll i = 0; i<v.size() && i < n-k; i++) {
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
11 ms |
2268 KB |
Output is correct |
17 |
Correct |
11 ms |
2352 KB |
Output is correct |
18 |
Correct |
11 ms |
2268 KB |
Output is correct |
19 |
Correct |
11 ms |
2264 KB |
Output is correct |
20 |
Correct |
11 ms |
2268 KB |
Output is correct |
21 |
Correct |
11 ms |
2268 KB |
Output is correct |
22 |
Correct |
11 ms |
2268 KB |
Output is correct |
23 |
Correct |
11 ms |
2268 KB |
Output is correct |
24 |
Correct |
11 ms |
2264 KB |
Output is correct |