# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
716637 | 2023-03-30T15:51:37 Z | vjudge1 | Stove (JOI18_stove) | C++17 | 1 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long int #define oo 1e15 + 9 #define pii pair<ll, int> const int MAX = 1e5 + 5; int arr[MAX]; int main(){ int n, k; cin >> n >> k; vector<int> dif; for(int i = 0; i < n; i++){ cin >> arr[i]; } for(int i = 0; i < n - 1; i++){ if(arr[i + 1] - arr[i] - 1){ dif.push_back(arr[i + 1] - arr[i] - 1); } } sort(dif.begin(), dif.end()); int ans = n; for (int i = 0; i < dif.size() - k + 1; i++) { ans += dif[i]; } cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |