답안 #52349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52349 2018-06-25T13:51:17 Z tmwilliamlin168 Stove (JOI18_stove) C++14
100 / 100
16 ms 1020 KB
#include <bits/stdc++.h>
using namespace std;

inline int in() {
	int result = 0;
	char ch = getchar_unlocked();
	while(true) {
		if(ch >= '0' && ch <= '9')
			break;
		ch = getchar_unlocked();
	}
	result = ch-'0';
	while(true) {
		ch = getchar_unlocked();
		if (ch < '0' || ch > '9')
			break;
		result = result*10 + (ch - '0');
	}
	return result;
}
inline void out(int x) {
	int rev=x, c=0;
	while(!(rev%10)) {
		++c;
		rev/=10;
	}
	rev=0;
	while(x) {
		rev=rev*10+x%10;
		x/=10;
	}
	while(rev) {
		putchar_unlocked(rev%10+'0');
		rev/=10;
	}
	while(c--)
		putchar_unlocked('0');
}

const int mxN=1e5;
int n, k, t1, t2, ans, d[mxN-1];

int main() {
	n=in(), k=in();
	for(int i=0; i<n; ++i) {
		t2=in();
		if(i)
			d[i-1]=t2-t1-1;
		t1=t2;
	}
	ans=n;
	sort(d, d+n-1);
	for(int i=0; i<n-k; ++i)
		ans+=d[i];
	out(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 552 KB Output is correct
10 Correct 3 ms 572 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 3 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 2 ms 492 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 3 ms 552 KB Output is correct
10 Correct 3 ms 572 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Correct 2 ms 636 KB Output is correct
13 Correct 2 ms 636 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 3 ms 636 KB Output is correct
16 Correct 13 ms 888 KB Output is correct
17 Correct 15 ms 1012 KB Output is correct
18 Correct 13 ms 1012 KB Output is correct
19 Correct 13 ms 1012 KB Output is correct
20 Correct 15 ms 1012 KB Output is correct
21 Correct 13 ms 1020 KB Output is correct
22 Correct 13 ms 1020 KB Output is correct
23 Correct 16 ms 1020 KB Output is correct
24 Correct 14 ms 1020 KB Output is correct