Submission #99146

# Submission time Handle Problem Language Result Execution time Memory
99146 2019-02-28T20:32:15 Z rzbt Stove (JOI18_stove) C++14
100 / 100
67 ms 2420 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 100005
typedef long long ll;


using namespace std;

int n,k;
int niz[MAXN];
vector<int> razmaci;

int main()
{
    scanf("%d %d", &n, &k);
    for(int i=1;i<=n;i++)
        scanf("%d", niz+i);

    sort(niz+1,niz+1+n);
    for(int i=2;i<=n;i++){
        razmaci.pb(niz[i]-niz[i-1]-1);
    }
    sort(all(razmaci),greater<int>());
    int res=niz[n]-niz[1]+1;
    for(int i=0;i<k-1;i++)res-=razmaci[i];

    printf("%d",res);


    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", niz+i);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 372 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 372 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 372 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 26 ms 2300 KB Output is correct
17 Correct 27 ms 2292 KB Output is correct
18 Correct 27 ms 2292 KB Output is correct
19 Correct 37 ms 2324 KB Output is correct
20 Correct 28 ms 2420 KB Output is correct
21 Correct 67 ms 2420 KB Output is correct
22 Correct 28 ms 2292 KB Output is correct
23 Correct 27 ms 2292 KB Output is correct
24 Correct 27 ms 2300 KB Output is correct