Submission #939313

# Submission time Handle Problem Language Result Execution time Memory
939313 2024-03-06T09:01:29 Z B_Shahrom Stove (JOI18_stove) C++17
100 / 100
16 ms 2300 KB
#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 time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 508 KB Output is correct
11 Correct 1 ms 504 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 14 ms 2272 KB Output is correct
17 Correct 14 ms 2248 KB Output is correct
18 Correct 14 ms 2236 KB Output is correct
19 Correct 14 ms 2272 KB Output is correct
20 Correct 14 ms 2272 KB Output is correct
21 Correct 16 ms 2272 KB Output is correct
22 Correct 15 ms 2300 KB Output is correct
23 Correct 14 ms 2272 KB Output is correct
24 Correct 15 ms 2272 KB Output is correct