Submission #939313

#TimeUsernameProblemLanguageResultExecution timeMemory
939313B_ShahromStove (JOI18_stove)C++17
100 / 100
16 ms2300 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ull unsigned long long int #define pb push_back #define pf push_front #define en cout<<endl; #define yes cout<<"YES\n"; #define no cout<<"NO\n"; #define no1 {cout<<-1<<'\n'; r0} #define no0 {cout<<0<<'\n'; r0} #define yes_r { cout<<"YES\n"; return ; } #define no_r { cout<<"NO\n"; return ; } #define r0 return ; #define fr first #define sc second #define srt(name) sort(name.begin(), name.end()); #define rev(name) reverse(name.begin(), name.end()); #define TT { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; int tt; cin>>tt; while (tt--) son_of_the_main(); } #define TT1 { son_of_the_main(); } #define TTi { while(1) son_of_the_main(); } #define IMP { cout<<"Impossible\n"; r0 } string all = "abcdefghijklmnopqrstuvwxyz"; string Call= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; string Vow = "aeiou"; const int INF=1e9+1; const int mod=998244353; const int N=1e6+10; void son_of_the_main() { int n, k; cin>>n>>k; int v[n]; vector<int> segs; for (int i=0; i<n; i++){ cin>>v[i]; if (i!=0) segs.pb(v[i]-v[i-1]-1); } srt(segs); int cnt=n; for (int i=0; i<n-k; i++){ cnt+=segs[i]; } cout<<cnt; } int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; TT1 } /* comment box */ /** **/ /* freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...