Submission #437238

# Submission time Handle Problem Language Result Execution time Memory
437238 2021-06-26T05:57:58 Z ToroTN Stove (JOI18_stove) C++14
0 / 100
1 ms 204 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100005],sum;
set<int> s;
int main()
{
    scanf("%d%d",&n,&m);
    sum=n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=2;i<=n;i++)
    {
        s.insert(a[i]-a[i-1]-1);
    }
    for(int i=1;i<=n-m;i++)
    {
        sum+=*s.begin();
        s.erase(*s.begin());
    }
    printf("%d\n",sum);
}

Compilation message

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,&m);
      |     ~~~~~^~~~~~~~~~~~~~
stove.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -