제출 #238586

#제출 시각아이디문제언어결과실행 시간메모리
238586rahul_a_nStove (JOI18_stove)C++14
0 / 100
187 ms66200 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int #define pb(x) push_back(x) #define PI pair<int,int> #define PL pair<long int,long int> #define PLL pair<ll,ll> #define Tcase int t;cin>>t;while(t--) #define MOD 1000000007 #define all(x) x.begin(),x.end() #define MAXN 200005 #define F first #define S second int main() { #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("input.txt", "r", stdin); // for writing output to output.txt freopen("output.txt", "w", stdout); #endif ll n, k; cin >> n >> k; long int t[n]; vector<long int>ans; for (int i = 0; i < n; i++)cin >> t[i]; for (int i = 0; i < n - 1; i++)ans.pb(t[i] - t[i + 1] + 1); ll tot = t[n - 1] - t[0] + 1; sort(all(ans)); for (int i = 0; i < k - 1; i++)tot += ans[i]; cout << tot << "\n"; }

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

stove.cpp: In function 'int main()':
stove.cpp:18:9: 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:20:9: 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...