Submission #66719

# Submission time Handle Problem Language Result Execution time Memory
66719 2018-08-12T07:26:11 Z yusufake Stove (JOI18_stove) C++
100 / 100
57 ms 10656 KB
#include<bits/stdc++.h> 
using namespace std; 

#define mp make_pair 
#define pb push_back 
#define st first 
#define nd second 

typedef long long ll; 
typedef pair < int , int > pp; 
const int mod = 1e9 + 7; 
const int N   = 3e5 + 5; 

priority_queue < int > Q;
int A[N],n,k,i,ans;

int main(){
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++) scanf("%d",&A[i]);
    sort(A+1 , A+n+1);
    ans = A[n] - A[1] + 1;
    
    for(i=2;i<=n;i++)
        Q.push(A[i]-A[i-1]-1);
    
    for(;--k;){
        ans -= Q.top();
        Q.pop();    
    }        
    
    printf("%d",ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:18: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:19:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++) scanf("%d",&A[i]);
                       ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 664 KB Output is correct
5 Correct 3 ms 664 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 3 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 664 KB Output is correct
5 Correct 3 ms 664 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 3 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 704 KB Output is correct
10 Correct 3 ms 752 KB Output is correct
11 Correct 3 ms 784 KB Output is correct
12 Correct 3 ms 832 KB Output is correct
13 Correct 4 ms 884 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 4 ms 964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 496 KB Output is correct
3 Correct 3 ms 496 KB Output is correct
4 Correct 3 ms 664 KB Output is correct
5 Correct 3 ms 664 KB Output is correct
6 Correct 3 ms 664 KB Output is correct
7 Correct 3 ms 664 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 704 KB Output is correct
10 Correct 3 ms 752 KB Output is correct
11 Correct 3 ms 784 KB Output is correct
12 Correct 3 ms 832 KB Output is correct
13 Correct 4 ms 884 KB Output is correct
14 Correct 3 ms 932 KB Output is correct
15 Correct 4 ms 964 KB Output is correct
16 Correct 29 ms 2928 KB Output is correct
17 Correct 25 ms 3908 KB Output is correct
18 Correct 34 ms 4864 KB Output is correct
19 Correct 28 ms 5844 KB Output is correct
20 Correct 35 ms 6784 KB Output is correct
21 Correct 57 ms 7776 KB Output is correct
22 Correct 38 ms 8728 KB Output is correct
23 Correct 39 ms 9692 KB Output is correct
24 Correct 40 ms 10656 KB Output is correct