제출 #1241915

#제출 시각아이디문제언어결과실행 시간메모리
1241915hello10Stove (JOI18_stove)C++20
100 / 100
12 ms2244 KiB
#include<bits/stdc++.h> #define int long long #define endl "\n" #define MAXN 1000005 #define inf 1e18 using namespace std; vector<int> p; int res=0, n, k; int a[MAXN]; signed main() { if (fopen("temp.inp", "r")){ freopen("temp.inp", "r", stdin); freopen("temp.out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>k; for (int i=1; i<=n; i++){ cin>>a[i]; } for (int i=1; i<=n-1; i++){ p.push_back(a[i+1]-a[i]); } sort (p.begin(), p.end()); for (int i=0; i<n-k; i++){ res+=p[i]; } res+=k; cout<<res; }

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

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