답안 #66726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
66726 2018-08-12T07:38:33 Z MrTEK Stove (JOI18_stove) C++14
100 / 100
44 ms 1640 KB
#include <bits/stdc++.h>

using namespace std;
#define mp make_pair
#define pb push_back
#define len(a) (int)a.size()
#define fi first
#define sc second
#define d1(w) cerr<<#w<<":"<<w<<endl;
#define d2(w,c) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<endl;
#define d3(w,c,z) cerr<<#w<<":"<<w<<" "<<#c<<":"<<c<<" "<<#z<<":"<<z<<endl;
#define left ind+ind
#define right ind+ind+1
#define mid (l+r)/2
#define FAST_IO ios_base::sync_with_stdio(false);
#define endl '\n'

typedef long long int ll;

const int maxn = 620;
const long long LINF = 1e18;
const int LOG = 31;
const int INF = 1e9;
const int N = 1e5 + 5;
const int M = 1e4 + 5;
const int SQ = 350;
const int MOD = 998244353;

typedef pair <int,int> pii;

int n,k,t[N];

long long ans;

vector <int> v;

int main() {
	
	scanf("%d %d",&n,&k);

	k--;

	for (int i = 1 ; i <= n ; i++) scanf("%d",&t[i]);

	sort(t + 1 , t + n + 1);

	for (int i = 1 ; i < n ; i++) {
		v.pb(t[i + 1] - t[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for (int i = 0 ; i < k ; i++) ans += v[i];
	printf("%lld\n",(t[n] - t[1] + 1) - ans + k);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
stove.cpp:43:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1 ; i <= n ; i++) scanf("%d",&t[i]);
                                 ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 404 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 3 ms 536 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 2 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 404 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 3 ms 536 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 2 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 540 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 4 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 4 ms 744 KB Output is correct
14 Correct 4 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 404 KB Output is correct
3 Correct 3 ms 536 KB Output is correct
4 Correct 3 ms 536 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 3 ms 540 KB Output is correct
7 Correct 2 ms 540 KB Output is correct
8 Correct 3 ms 540 KB Output is correct
9 Correct 3 ms 540 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 4 ms 744 KB Output is correct
12 Correct 3 ms 744 KB Output is correct
13 Correct 4 ms 744 KB Output is correct
14 Correct 4 ms 744 KB Output is correct
15 Correct 4 ms 744 KB Output is correct
16 Correct 32 ms 1640 KB Output is correct
17 Correct 34 ms 1640 KB Output is correct
18 Correct 35 ms 1640 KB Output is correct
19 Correct 33 ms 1640 KB Output is correct
20 Correct 34 ms 1640 KB Output is correct
21 Correct 44 ms 1640 KB Output is correct
22 Correct 33 ms 1640 KB Output is correct
23 Correct 31 ms 1640 KB Output is correct
24 Correct 33 ms 1640 KB Output is correct