Submission #330731

#TimeUsernameProblemLanguageResultExecution timeMemory
330731TLP39Stove (JOI18_stove)C++14
100 / 100
29 ms1644 KiB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int t,s;
    scanf("%d",&t);
    int beg=t;
    int d[n]={};
    for(int i=0;i<n-1;i++)
    {
        scanf("%d",&s);
        d[i]=s-t-1;
        t=s;
    }
    sort(d,d+n-1,greater<int>());
    int ans=t-beg+1;
    for(int i=0;i<k-1;i++)
    {
        ans-=d[i];
    }
    printf("%d",ans);
}

Compilation message (stderr)

stove.cpp: In function 'int main()':
stove.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d %d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~~
stove.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d",&t);
      |     ~~~~~^~~~~~~~~
stove.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         scanf("%d",&s);
      |         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...