답안 #127291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127291 2019-07-09T07:53:36 Z newbee Stove (JOI18_stove) C++17
100 / 100
30 ms 3584 KB
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

#define int long long
const int MAX = 1e5 + 15;

int aGuest;
int aMatch;
std::vector<int> Time;
std::vector<int> diff;

signed main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);

  std::cin >> aGuest >> aMatch;
  for (int i = 0; i < aGuest; ++i) {
    int inp;
    std::cin >> inp;
    Time.push_back(inp);
  }

  for (int i = 1; i < aGuest; ++i) {
    diff.push_back(Time[i] - Time[i - 1]);
  }

  std::sort(diff.begin(), diff.end());
  int ans = 0;

  for (int i = 0; i < aGuest - aMatch; ++i) {
    ans += diff[i];
  }

  std::cout << ans + aMatch;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 296 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 27 ms 3568 KB Output is correct
17 Correct 27 ms 3568 KB Output is correct
18 Correct 30 ms 3584 KB Output is correct
19 Correct 27 ms 3568 KB Output is correct
20 Correct 26 ms 3564 KB Output is correct
21 Correct 27 ms 3568 KB Output is correct
22 Correct 27 ms 3564 KB Output is correct
23 Correct 27 ms 3564 KB Output is correct
24 Correct 27 ms 3568 KB Output is correct