Submission #390061

#TimeUsernameProblemLanguageResultExecution timeMemory
390061ioiStove (JOI18_stove)C++14
100 / 100
54 ms1808 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n , k ; cin >> n >> k ; k -- ; vector<int> v ; int past , f ; for(int i = 0 ; i < n; i ++){ int a ; cin >> a ; if(i == 0)f = a ; if(i)v.push_back(a - past - 1); past = a ; } int ans = past + 1 - f ; sort(v.rbegin() , v.rend()); for(int i = 0 ; i < k ; i ++) ans -= v[i]; cout << ans ; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:24:20: warning: 'past' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     int ans = past + 1 - f ;
      |               ~~~~~^~~
stove.cpp:24:9: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   24 |     int ans = past + 1 - f ;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...