# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
76858 | 2018-09-18T18:16:43 Z | Vardanyan | Stove (JOI18_stove) | C++14 | 3 ms | 764 KB |
#include <bits/stdc++.h> using namespace std; const int N = 5007; long long a[N]; long long dif[N]; int main(){ int n,k; scanf("%d%d",&n,&k); for(int i = 1;i<=n;i++){ scanf("%lld",&a[i]); if(i>1) dif[i] = a[i]-a[i-1]; } sort(dif+1,dif+1+n); reverse(dif+1,dif+1+n); long long c = 0; for(int i = 1;i<=k-1;i++)c+=dif[i]; c = a[n]-a[1]+k-c; printf("%lld\n",c); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 544 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 544 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 3 ms | 544 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 596 KB | Output is correct |
13 | Correct | 3 ms | 596 KB | Output is correct |
14 | Correct | 3 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 544 KB | Output is correct |
6 | Correct | 2 ms | 544 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 3 ms | 544 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 596 KB | Output is correct |
13 | Correct | 3 ms | 596 KB | Output is correct |
14 | Correct | 3 ms | 596 KB | Output is correct |
15 | Correct | 3 ms | 596 KB | Output is correct |
16 | Execution timed out | 3 ms | 764 KB | Time limit exceeded (wall clock) |
17 | Halted | 0 ms | 0 KB | - |