Submission #81232

# Submission time Handle Problem Language Result Execution time Memory
81232 2018-10-24T07:37:29 Z farukkastamonuda Stove (JOI18_stove) C++14
100 / 100
30 ms 10468 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
#define pi pair<lo int, int>
using namespace std;
int n, k, T[li], cev;
vector<int> v;
int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i <= n ; i ++){
		scanf("%d", &T[i]);
		if(i > 1) v.pb(T[i] - T[i - 1] -1);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i = 1; i < k; i ++){
		cev += v[i - 1];
	}
	printf("%d\n", T[n] - T[1] + 1 - cev);
	return 0;
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:15: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:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &T[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 3 ms 524 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Correct 3 ms 792 KB Output is correct
13 Correct 3 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 460 KB Output is correct
7 Correct 2 ms 460 KB Output is correct
8 Correct 2 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 3 ms 524 KB Output is correct
11 Correct 3 ms 572 KB Output is correct
12 Correct 3 ms 792 KB Output is correct
13 Correct 3 ms 792 KB Output is correct
14 Correct 3 ms 792 KB Output is correct
15 Correct 3 ms 792 KB Output is correct
16 Correct 28 ms 2612 KB Output is correct
17 Correct 28 ms 3656 KB Output is correct
18 Correct 27 ms 4684 KB Output is correct
19 Correct 28 ms 5692 KB Output is correct
20 Correct 29 ms 6712 KB Output is correct
21 Correct 30 ms 7576 KB Output is correct
22 Correct 28 ms 8532 KB Output is correct
23 Correct 29 ms 9500 KB Output is correct
24 Correct 29 ms 10468 KB Output is correct