답안 #548875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548875 2022-04-14T15:32:00 Z DemonLord154 Stove (JOI18_stove) C++14
100 / 100
59 ms 1400 KB
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int solve(int n, vector<int> & times, int k){
 	vector<int> gaps(n-1);
  for (int i=0;i<n-1;i++){
    gaps[i]=times[i+1]-times[i]-1;
  }
  sort(gaps.begin(),gaps.end(),greater<int>());
  int answer= times[n-1]-times[0]+1;
  for (int i=0;i<k-1;i++){
    answer-=gaps[i];
  }
  return answer;
}
int main(){
  int n,k;
  cin>>n>>k;
  vector <int> times(n);
  for (int i=0;i<n;i++){
    cin>>times[i];
  }
  cout<<solve(n,times,k)<<"\n";
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 224 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 224 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 312 KB Output is correct
16 Correct 59 ms 1356 KB Output is correct
17 Correct 50 ms 1400 KB Output is correct
18 Correct 59 ms 1392 KB Output is correct
19 Correct 52 ms 1396 KB Output is correct
20 Correct 58 ms 1384 KB Output is correct
21 Correct 54 ms 1372 KB Output is correct
22 Correct 49 ms 1376 KB Output is correct
23 Correct 58 ms 1372 KB Output is correct
24 Correct 50 ms 1384 KB Output is correct