제출 #171147

#제출 시각아이디문제언어결과실행 시간메모리
171147Nodir_BobievStove (JOI18_stove)C++14
0 / 100
7 ms632 KiB
# include <bits/stdc++.h> # define FILE using namespace std; int main(){ # ifdef FILE freopen( "input.txt", "r", stdin ); freopen( "output.txt", "w", stdout ); # endif ios_base::sync_with_stdio( false ); int n, k; cin >> n >> k; vector < int > times; for( int i = 0; i < n;i ++ ){ int tt; cin >> tt; times.push_back( tt ); } int ans = times.back()-times[0]+1; vector < int > diff; for( int i = 0; i < n-1; i ++ ){ diff.push_back( times[i+1]-times[i]-1 ); } sort( diff.rbegin(), diff.rend() ); for( int i = 0; i < k -1; i ++ ) ans -= diff[i]; cout << ans; return 0; }

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

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