Submission #331761

# Submission time Handle Problem Language Result Execution time Memory
331761 2020-11-30T01:37:46 Z daniel920712 Stove (JOI18_stove) C++14
100 / 100
28 ms 2152 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;
vector < int > all;
int when[100005]={0};
int main()
{
    int N,M,ans=0,i;
    scanf("%d %d",&N,&M);
    ans=N;
    for(i=0;i<N;i++)
    {
        scanf("%d",&when[i]);
        if(i) all.push_back(when[i]-when[i-1]-1);
    }
    sort(all.begin(),all.end());
    for(i=0;i<N-M;i++) ans+=all[i];
    printf("%d\n",ans);
    return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |     scanf("%d %d",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~~
stove.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |         scanf("%d",&when[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 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 1 ms 364 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 27 ms 2152 KB Output is correct
17 Correct 23 ms 2152 KB Output is correct
18 Correct 23 ms 2152 KB Output is correct
19 Correct 23 ms 2152 KB Output is correct
20 Correct 23 ms 2152 KB Output is correct
21 Correct 23 ms 2152 KB Output is correct
22 Correct 28 ms 2152 KB Output is correct
23 Correct 23 ms 2152 KB Output is correct
24 Correct 24 ms 2152 KB Output is correct