Submission #330789

# Submission time Handle Problem Language Result Execution time Memory
330789 2020-11-26T14:55:32 Z M_W Stove (JOI18_stove) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, K, old, cur;
	int f, l;
	vector<int> v;
	scanf("%d %d %d", &N, &K, &old);
	f = old;
	for(int i = 1; i < N; i++){
		scanf("%d", &cur);
		if(i == N - 1) l = cur;
		v.push_back(cur - old - 1);
		old = cur;
	}
	sort(v.begin(), v.end(), greater<int>());
	int ans = l - f + 1, cnt = 0;
	for(auto x : v){
		if(cnt >= K - 1) break;
		ans -= x;
		cnt++;
	}
	printf("%d", ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  scanf("%d %d %d", &N, &K, &old);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |   scanf("%d", &cur);
      |   ~~~~~^~~~~~~~~~~~
stove.cpp:16:14: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   16 |  int ans = l - f + 1, cnt = 0;
      |            ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 0 ms 364 KB Output isn't correct