Submission #1010730

#TimeUsernameProblemLanguageResultExecution timeMemory
1010730ASGA_RedSeaStove (JOI18_stove)C++17
100 / 100
40 ms6496 KiB
/** * بسم الله الرحمن الرحيم * ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿ */ /// author : "ASGA" #pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; using ll = long long; #define ONLINE 0 #ifdef ONLINE_JUDGE #undef ONLINE; #define ONLINE 1 #endif #define dbg(a) if(!ONLINE)cout << a << ' '; const ll inf = 1e18; signed main(){ ios_base::sync_with_stdio(0);cin.tie(); int n,k;cin >> n >> k; vector <int> a(n); for(int& i : a)cin >> i; ll ans = a.back() + 1 - a[0]; multiset <int> s; for(int i = 0;i + 1 < n;i++)s.insert(a[i + 1] - a[i]); auto i = s.rbegin(); while(--k){ans -= (*i++);ans++;} cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...