제출 #1273413

#제출 시각아이디문제언어결과실행 시간메모리
1273413nhq0914Stove (JOI18_stove)C++17
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5; int n, k; int ans; int t[maxn]; int gap[maxn], cnt; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); freopen("data.txt", "r", stdin); cin >> n >> k; for(int i = 0; i < n; ++i){ cin >> t[i]; if(i == 0 || t[i - 1] + 1 == t[i]) continue; gap[cnt++] = t[i] - t[i - 1] - 1; } ans = t[n - 1] - t[0] + 1; sort(gap, gap + cnt, greater <int> ()); cnt = min(cnt, k - 1); for(int i = 0; i < cnt; ++i) ans -= gap[i]; cout << ans; return 0; }

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

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