# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
718702 | 2023-04-04T14:30:25 Z | AndrijaM | Stove (JOI18_stove) | C++14 | 49 ms | 3140 KB |
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(true); long long n; long long k; cin>>n>>k; long long x[n+1]; long long mx=0; long long mi=1e18; for(long long i=1;i<=n;i++) { cin>>x[i]; } vector<long long>a; for(long long i=2;i<=n;i++) { a.push_back(x[i]-x[i-1]-1); } sort(a.rbegin(),a.rend()); long long ans=x[n]-x[1]+1; for(long long i=0;i<k-1;i++) { ans-=a[i]; } cout<<ans<<endl; return 0; }
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 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 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 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 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 | Correct | 1 ms | 212 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 | 344 KB | Output is correct |
14 | Correct | 2 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 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 | Correct | 1 ms | 212 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 | 344 KB | Output is correct |
14 | Correct | 2 ms | 340 KB | Output is correct |
15 | Correct | 2 ms | 340 KB | Output is correct |
16 | Correct | 43 ms | 3084 KB | Output is correct |
17 | Correct | 44 ms | 3092 KB | Output is correct |
18 | Correct | 43 ms | 3084 KB | Output is correct |
19 | Correct | 49 ms | 3084 KB | Output is correct |
20 | Correct | 48 ms | 3080 KB | Output is correct |
21 | Correct | 45 ms | 3140 KB | Output is correct |
22 | Correct | 46 ms | 3140 KB | Output is correct |
23 | Correct | 43 ms | 3092 KB | Output is correct |
24 | Correct | 45 ms | 3092 KB | Output is correct |