Submission #868909

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

int main(){
  int n,k;
  int x[n];
  int y[n];
  int sum=0;
  
  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];
      |          ^
stove.cpp:19:18: warning: 'k' is used uninitialized in this function [-Wuninitialized]
   19 |   for(int i=0;i<n-k;i++){
      |                 ~^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -