답안 #284594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284594 2020-08-27T17:08:49 Z triplem5ds Stove (JOI18_stove) C++14
100 / 100
96 ms 2292 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;
string s;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  vector<int> times;
  int ans = n;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    if(i)times.push_back(v[i] - v[i-1] - 1);
  }

  sort(times.begin(),times.end());
  k = n - k;
  times.resize(k);

  cout << ans + accumulate(times.begin(),times.end(),0ll) << endl;


  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 92 ms 2164 KB Output is correct
17 Correct 92 ms 2212 KB Output is correct
18 Correct 96 ms 2292 KB Output is correct
19 Correct 94 ms 2292 KB Output is correct
20 Correct 92 ms 2164 KB Output is correct
21 Correct 93 ms 2272 KB Output is correct
22 Correct 93 ms 2292 KB Output is correct
23 Correct 95 ms 2168 KB Output is correct
24 Correct 92 ms 2292 KB Output is correct