제출 #831322

#제출 시각아이디문제언어결과실행 시간메모리
831322manhtuan22007Stove (JOI18_stove)C++14
100 / 100
18 ms3240 KiB
#include <bits/stdc++.h> #define int long long #define ll long long using namespace std; const int maxn = 1e5 + 10; int n , k , a[maxn]; int32_t main() { cin.tie(0)->sync_with_stdio(0); if(fopen(".inp" , "r")){ freopen(".inp" , "r" , stdin); freopen(".out" , "w" , stdout); } cin >> n >> k; for(int i = 1 ; i <= n ; i ++) cin >> a[i]; vector<int> v; for(int i = 2 ; i <= n ; i ++){ v.push_back(a[i] - a[i - 1] - 1); } sort(v.begin() , v.end()); int res = a[n] - a[1] + 1; for(int i = n - 2 ; i >= n - k ; i --){ res -= v[i]; } cout << res; }

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

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