Submission #1241909

#TimeUsernameProblemLanguageResultExecution timeMemory
1241909trantien3771Stove (JOI18_stove)C++20
100 / 100
13 ms3012 KiB
#include <bits/stdc++.h> #define int long long const int maxn = 2e5 + 5; const int mod = 11229837253; using namespace std; main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k, a[maxn]; cin >> n >> k; vector<int> v; for (int i = 1; i <= n; i++){ cin >> a[i]; if (i >= 2) v.push_back(a[i] - a[i - 1]); } sort(v.begin(), v.end()); int sum = 0; for (int i = 1; i <= n - k; i++){ sum += v[i - 1]; } cout << sum + k; return 0; }

Compilation message (stderr)

stove.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...