Submission #153342

# Submission time Handle Problem Language Result Execution time Memory
153342 2019-09-13T13:40:26 Z mhy908 Stove (JOI18_stove) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
int n,k,t[100010],arr[100010],ans,i;
main()
{
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++)scanf("%d", &t[i]);
    for(i=2;i<=n;i++)arr[i-1]=t[i]-t[i-1]-1;
    std::sort(arr+1, arr+n);
    for(i=1;i<=n-k-1;i++)ans+=arr[i];
    printf("%d", ans+n);
}

Compilation message

stove.cpp:3:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
stove.cpp: In function 'int main()':
stove.cpp:5: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:6:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%d", &t[i]);
                      ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -