답안 #41599

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41599 2018-02-19T19:05:47 Z Abelyan Stove (JOI18_stove) C++14
100 / 100
35 ms 1516 KB
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

#define mpr make_pair
#define pr pair<int,long long>
#define st string
#define vint vector<int>
#define vpr vector<pr>
#define fr first
#define sc second
#define add push_back
#define del pop_back
#define qdel pop
inline int scn() { int hg; scanf("%d",&hg); return hg; };

const int N=100006;
int a[N],b[N];

int main(){
    ios_base::sync_with_stdio(false);
    int n=scn();
    int k=scn();
    for (int i=0;i<n;i++){
        a[i]=scn();
        if (i>0){
            b[i-1]=a[i]-a[i-1]-1;
        }
    }
    sort(b,b+n-1);
    int ans=n;
    for (int i=0;i<n-k;i++){
        ans+=b[i];
    }
    cout<<ans<<endl;
	return 0;
}

Compilation message

stove.cpp: In function 'int scn()':
stove.cpp:15:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 inline int scn() { int hg; scanf("%d",&hg); return hg; };
                                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 536 KB Output is correct
5 Correct 1 ms 536 KB Output is correct
6 Correct 1 ms 536 KB Output is correct
7 Correct 1 ms 536 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 536 KB Output is correct
5 Correct 1 ms 536 KB Output is correct
6 Correct 1 ms 536 KB Output is correct
7 Correct 1 ms 536 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 248 KB Output is correct
2 Correct 1 ms 352 KB Output is correct
3 Correct 1 ms 404 KB Output is correct
4 Correct 1 ms 536 KB Output is correct
5 Correct 1 ms 536 KB Output is correct
6 Correct 1 ms 536 KB Output is correct
7 Correct 1 ms 536 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 2 ms 600 KB Output is correct
11 Correct 3 ms 600 KB Output is correct
12 Correct 2 ms 600 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 25 ms 1388 KB Output is correct
17 Correct 25 ms 1388 KB Output is correct
18 Correct 32 ms 1392 KB Output is correct
19 Correct 26 ms 1392 KB Output is correct
20 Correct 35 ms 1392 KB Output is correct
21 Correct 25 ms 1392 KB Output is correct
22 Correct 26 ms 1516 KB Output is correct
23 Correct 27 ms 1516 KB Output is correct
24 Correct 31 ms 1516 KB Output is correct