Submission #123090

#TimeUsernameProblemLanguageResultExecution timeMemory
123090HideoStove (JOI18_stove)C++14
100 / 100
28 ms2284 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mk make_pair #define fr first #define sc second #define vi vector < int > #define vl vector < ll > #define pi pair < int, ll > #define pii pair < int, pi > #define vii vector < pi > const int N = 3e5 + 7; const int INF = 1e9 + 7; int a[N]; int n, k; ll ans; vi dif; main(){ cin >> n >> k; ans = n; for (int i = 1; i <= n; i++){ scanf("%d", &a[i]); if (i > 1) dif.pb(a[i] - a[i - 1] - 1); } sort(dif.begin(), dif.end()); for (int i = 0; i < n - k; i++) ans += dif[i]; cout << ans; }

Compilation message (stderr)

stove.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
stove.cpp: In function 'int main()':
stove.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...