# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
708449 | 2023-03-11T19:22:47 Z | deme_bz | Stove (JOI18_stove) | C++14 | 1 ms | 340 KB |
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define eb emplace_back #define sz(x) (int)x.size() using namespace std; const int N=2e5+5; ll A[N]; void test_case(){ //cout << INT_MAX+1 << endl; int n,k; cin >> n >> k; for(int i=1;i<=n;i++){ cin >> A[i]; } vector<ll> v; for(int i=2;i<=n;i++){ v.pb(A[i]-A[i-1]-1); } sort(all(v)); ll answer=A[n]-A[1]+1; //cout << v.size()-1 << endl; if(v.size()>0){ for(int i=v.size()-1;i>=v.size()+1-k;i--){ answer-=v[i]; } } cout << answer << endl; } main(){ //ios_base::sync_with_stdio(false); int T = 1; //cin >> T; while(T--){ test_case(); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 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 | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |