제출 #1268594

#제출 시각아이디문제언어결과실행 시간메모리
1268594duyanhloveavStove (JOI18_stove)C++20
100 / 100
13 ms2380 KiB
#include <bits/stdc++.h> using namespace std; #define MASK(i) (1LL << (i)) #define BIT(x, i) (((x) >> (i)) & 1LL) using ll = long long; const int mxn = 9 + 1e6; const int inf = 0x3f3f3f3f; const ll lnf = 0x3f3f3f3f3f3f3f3f; #define int long long void _27augain(void) { int n, k; cin >> n >> k; vector<int> a(n); for (auto &x : a) { cin >> x; } vector<int> d; for (int i = 1; i < n; ++i) { d.push_back(a[i] - a[i - 1] - 1); } int s = a[n - 1] + 1 - a[0]; sort(rbegin(d), rend(d)); for (int i = 0; i < k - 1; ++i) { s -= d[i]; } cout << s << "\n"; } int32_t main(void) { #define task "_27augain" cin.tie(0)->sync_with_stdio(0); for (string iext : {"in", "inp"}) { if (fopen((task "." + iext).c_str(), "r")) { freopen((task "." + iext).c_str(), "r", stdin); freopen(task ".out", "w", stdout); } } int testcase = 1; // cin >> testcase; while (testcase--) { _27augain(); } return 0; }

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

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