답안 #206255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206255 2020-03-02T20:20:25 Z hhh07 Stove (JOI18_stove) C++14
100 / 100
76 ms 3056 KB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  long long t[n];
  vector<long long> r;
  long long res = 0;
  for (int i = 0; i < n; i++){
    cin >> t[i];
    if (i > 0)
      r.push_back(t[i] - t[i - 1]);
  }

  sort(r.begin(), r.end());
  for (int i = 0 ; i < n - k; i++){
    res += r[i];
  }

  cout << res + k << endl;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 248 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 504 KB Output is correct
15 Correct 7 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 248 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 7 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 504 KB Output is correct
15 Correct 7 ms 380 KB Output is correct
16 Correct 76 ms 2928 KB Output is correct
17 Correct 75 ms 2928 KB Output is correct
18 Correct 75 ms 2932 KB Output is correct
19 Correct 73 ms 3056 KB Output is correct
20 Correct 76 ms 3052 KB Output is correct
21 Correct 73 ms 2928 KB Output is correct
22 Correct 74 ms 3048 KB Output is correct
23 Correct 74 ms 2928 KB Output is correct
24 Correct 75 ms 3048 KB Output is correct