답안 #219807

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
219807 2020-04-06T12:15:35 Z Nightlight Stove (JOI18_stove) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

int N, K;
int best[100005];

int main() {
  scanf("%d %d", &N, &K);
  int last, now, pertamax, terakhir;
  scanf("%d", &pertamax);
  last = pertamax;
  for(int i = 2; i < N; i++) {
    scanf("%d", &now);
    best[i - 1] = now - last - 1;
    last = now;
  }
  scanf("%d", &terakhir);
  best[N - 1] = terakhir - last - 1;
  sort(best + 1, best + N + 1, greater<int>());
  int ans = terakhir - pertamax + 1;
  for(int i = 1; i < K; i++) {
    ans -= best[i];
  }
  printf("%d", ans);
}

Compilation message

stove.cpp: In function 'int main()':
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &N, &K);
   ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &pertamax);
   ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &now);
     ~~~~~^~~~~~~~~~~~
stove.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &terakhir);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Incorrect 5 ms 384 KB Output isn't correct