Submission #312421

# Submission time Handle Problem Language Result Execution time Memory
312421 2020-10-13T06:52:05 Z Karliver Stove (JOI18_stove) C++14
100 / 100
20 ms 1792 KB
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define loop(i,a,b) for (int i=a; i<b; ++i)
using ll = long long;
const int mod = 998244353;
typedef pair<int , int> pairs;
typedef complex<ll> G;

const int N = 1e3 + 5;

int power(int a,int b){
    if(!b)
        return 1;
    int c=power(a,b/2);
    c=(1LL*c*c)%mod;
    if(b%2)
        c=(1LL*c*a)%mod;
    return c;
}


void done() {


}

/*string solve_palindrome(const string& s)
{
    string a = s;
    reverse(a.begin(), a.end());
    //a = s + "#" + a;
    int c = 0;
    for (int i = 1; i < (int)a.size(); i++)
    {
        while (c != 0 && a[c] != a[i])
            c = pref[c - 1];
        if (a[c] == a[i])
            c++;
        pref[i] = c;
    }
    return s.substr(0, c);
}
*/

/*3
3 7 7 9 11
4 6 6 7*/
void solve()
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0;i < n;++i) {
        cin >> a[i];
    }
    for(int i = n - 1;i > 0;--i) {
        a[i] -= a[i - 1] + 1;
    }
    sort(a + 1,a + n);
    ll ans = n;
    for(int i = 1;i <= n-k;++i) {
        ans += a[i];
    }
    cout << ans << '\n';


}




void another() {


}

void test_case() {
    int t;
    cin >> t;
    while(t--)another();
}
int main() {

    ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);

    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 20 ms 1664 KB Output is correct
17 Correct 20 ms 1664 KB Output is correct
18 Correct 20 ms 1664 KB Output is correct
19 Correct 20 ms 1792 KB Output is correct
20 Correct 20 ms 1664 KB Output is correct
21 Correct 20 ms 1664 KB Output is correct
22 Correct 20 ms 1792 KB Output is correct
23 Correct 20 ms 1664 KB Output is correct
24 Correct 19 ms 1664 KB Output is correct