제출 #1228919

#제출 시각아이디문제언어결과실행 시간메모리
1228919HduongStove (JOI18_stove)C++20
100 / 100
13 ms1988 KiB
#include <bits/stdc++.h> #define task "task" using namespace std; const long long INF = 1e18; const int N = 1e5 + 5; long long a[N], n, k, b[N], s = 0; int main() { ios_base::sync_with_stdio(false); cin.tie(0); if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; long long res = a[n] - a[1] + 1; for (int i = 1; i < n; i++) { b[++s] = a[i + 1] - a[i] - 1; } // cout << s << " "; sort(b + 1, b + s + 1, greater <long long>()); for (int i = 1; i < k; i++) res -= b[i]; cout << res; }

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

stove.cpp: In function 'int main()':
stove.cpp:14:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:15:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen (task".out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...