Submission #76859

# Submission time Handle Problem Language Result Execution time Memory
76859 2018-09-18T18:17:46 Z Vardanyan Stove (JOI18_stove) C++14
100 / 100
33 ms 10540 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5007*107;
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

stove.cpp: In function 'int main()':
stove.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
stove.cpp:10:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld",&a[i]);
             ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 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 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 680 KB Output is correct
14 Correct 3 ms 680 KB Output is correct
15 Correct 3 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 536 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 2 ms 576 KB Output is correct
8 Correct 2 ms 580 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 3 ms 596 KB Output is correct
12 Correct 3 ms 596 KB Output is correct
13 Correct 3 ms 680 KB Output is correct
14 Correct 3 ms 680 KB Output is correct
15 Correct 3 ms 680 KB Output is correct
16 Correct 29 ms 2812 KB Output is correct
17 Correct 28 ms 3800 KB Output is correct
18 Correct 30 ms 4756 KB Output is correct
19 Correct 30 ms 5720 KB Output is correct
20 Correct 28 ms 6684 KB Output is correct
21 Correct 29 ms 7648 KB Output is correct
22 Correct 26 ms 8612 KB Output is correct
23 Correct 28 ms 9704 KB Output is correct
24 Correct 33 ms 10540 KB Output is correct