제출 #330786

#제출 시각아이디문제언어결과실행 시간메모리
330786M_WStove (JOI18_stove)C++14
100 / 100
27 ms2048 KiB
#include <bits/stdc++.h> using namespace std; int g[100100], d[100100]; int main(){ int N, K; scanf("%d %d", &N, &K); for(int i = 0; i < N; i++) scanf("%d", &g[i]); for(int i = 0; i < N - 1; i++) d[i] = g[i + 1] - g[i] - 1; sort(d, d + N - 1, greater<int>()); int ans = g[N - 1] - g[0] + 1; for(int i = 0; i < K - 1; i++){ ans -= d[i]; } printf("%d", ans); }

컴파일 시 표준 에러 (stderr) 메시지

stove.cpp: In function 'int main()':
stove.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    6 |  scanf("%d %d", &N, &K);
      |  ~~~~~^~~~~~~~~~~~~~~~~
stove.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |   scanf("%d", &g[i]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...