# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
330020 | 2020-11-23T12:46:49 Z | sazid_alam | Stove (JOI18_stove) | C++17 | 25 ms | 3200 KB |
//Bismillahir Rahmanir Rahim #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef vector<int> vi; typedef vector<pair<int, int>> vpi; #define pb push_back #define pf push_front #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define ff first #define ss second #define mp make_pair #define lb lower_bound #define ub upper_bound #define Tcase() int t; cin >> t; while(t--) #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define F0R(i, a) FOR(i, 0, a) const ll MOD = 1e9 + 7; //998244353; const ll INF = 1e18; const int MX = 2e5 + 5; const ld PI = acos((ld) -1); const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; void setIO(string name = "") { ios_base::sync_with_stdio(0); cin.tie(0); if(sz(name)){ freopen((name+".in").c_str(), "r", stdin); freopen((name+".out").c_str(), "w", stdout); } } int main(){ setIO(); ll n, k; cin >> n >> k; ll a[n] = {0}; F0R(i, n) cin >> a[i]; sort(a, a + n); vector<ll> Diff; FOR(i, 1, n) Diff.pb(a[i] - a[i - 1]); sort(all(Diff)); ll Ans = n; F0R(i, n - k) Ans += Diff[i] - 1; cout << Ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 512 KB | Output is correct |
16 | Correct | 24 ms | 3200 KB | Output is correct |
17 | Correct | 23 ms | 3180 KB | Output is correct |
18 | Correct | 23 ms | 3180 KB | Output is correct |
19 | Correct | 23 ms | 3180 KB | Output is correct |
20 | Correct | 24 ms | 3180 KB | Output is correct |
21 | Correct | 23 ms | 3180 KB | Output is correct |
22 | Correct | 23 ms | 3200 KB | Output is correct |
23 | Correct | 24 ms | 3180 KB | Output is correct |
24 | Correct | 25 ms | 3180 KB | Output is correct |