# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
831320 | 2023-08-20T04:37:15 Z | manhtuan22007 | Stove (JOI18_stove) | C++14 | 1 ms | 464 KB |
#include <bits/stdc++.h> #define int long long #define ll long long using namespace std; const int maxn = 1e5 + 10; int n , k , a[maxn]; int32_t main() { cin.tie(0)->sync_with_stdio(0); if(fopen(".inp" , "r")){ freopen(".inp" , "r" , stdin); freopen(".out" , "w" , stdout); } cin >> n >> k; for(int i = 1 ; i <= n ; i ++) cin >> a[i]; vector<int> v; for(int i = 2 ; i <= n ; i ++){ v.push_back(a[i] - a[i - 1] - 1); } sort(v.begin() , v.end()); int res = a[n] - a[1] + 1; for(int i = n - 1 ; i >= n - k ; i --){ res -= v[i]; } cout << res; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Runtime error | 1 ms | 464 KB | Execution killed with signal 11 |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Runtime error | 1 ms | 464 KB | Execution killed with signal 11 |
10 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Runtime error | 1 ms | 464 KB | Execution killed with signal 11 |
10 | Halted | 0 ms | 0 KB | - |