제출 #731107

#제출 시각아이디문제언어결과실행 시간메모리
731107sleepntsheepStove (JOI18_stove)C++17
100 / 100
30 ms1700 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, k; long long z = 0; scanf("%d%d", &n, &k); auto t = new int[n]; for (int i = 0; i < n; i++) scanf("%d", t+i); sort(t, t+n); z = t[n-1] - t[0] + 1; for (int i = 1; i < n; i++) t[i-1] = t[i] - t[i-1]; sort(t, t+n-1, greater<int>()); for (int i = 0; i < k - 1; i++) z -= t[i] - 1; printf("%lld", z); delete []t; return 0; }

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

stove.cpp: In function 'int main()':
stove.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d%d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~
stove.cpp:9:38: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     for (int i = 0; i < n; i++) scanf("%d", t+i);
      |                                 ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...