Submission #868912

# Submission time Handle Problem Language Result Execution time Memory
868912 2023-11-02T12:27:05 Z F_Universe Stove (JOI18_stove) C++14
0 / 100
21 ms 47696 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,k;
  int x[n];
  int y[n];
  int sum=0;
  cin >>n >>k;
  y[0]=0;
  for(int i=0;i<n;i++){
    cin >>x[i];
  }
  for(int i=1;i<n;i++){
    y[i]=x[i]-x[i-1];
    
  }
  sort(y,y+n);
  for(int i=0;i<n-k;i++){
    sum+=y[i]+1;
  }
  printf("%d",sum);

  
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:6:10: warning: 'n' is used uninitialized in this function [-Wuninitialized]
    6 |   int x[n];
      |          ^
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 47696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 47696 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 47696 KB Output isn't correct
2 Halted 0 ms 0 KB -