답안 #330778

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330778 2020-11-26T14:38:58 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;
	for(int i = 0; i < K - 1; i++){
		ans -= v[i];
	}
	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;
      |            ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct