Submission #91257

#TimeUsernameProblemLanguageResultExecution timeMemory
91257AlisabziStove (JOI18_stove)C++14
100 / 100
23 ms10280 KiB
#include<bits/stdc++.h> using namespace std ; typedef long long ll ; #define F first #define S second const ll N = 100411 ; vector < int > a ; int n, k, b, x; int main () { scanf("%d%d", &n, &k) ; scanf("%d", &b) ; for(int i = 2 ; i <= n ; i ++){ scanf("%d", &x) ; a.push_back(x-b) ; b = x ; } if(n == 1) return cout << 1 , 0 ; sort(a.begin(), a.end()) ; ll ans = n ; for(int i = 0 ; i < n-k ; i ++){ ans += a[i]-1 ; } cout << ans ; }

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k) ;
  ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &b) ;
  ~~~~~^~~~~~~~~~
stove.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x) ;
   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...