제출 #1131441

#제출 시각아이디문제언어결과실행 시간메모리
1131441kemStove (JOI18_stove)C++20
100 / 100
17 ms1476 KiB
#include <bits/stdc++.h> // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2") using namespace std; #define NAME "stove" #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second #define endl "\n" #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() const int LIM = 2e5 + 3; const int INF = 1e9 + 9; const int mod = 1e9 + 7; int n, k, _t, t; vector<ll> d; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (ifstream(NAME ".inp")) { freopen(NAME ".inp", "r", stdin); freopen(NAME ".out", "w", stdout); } cin >> n >> k >> _t; for (int i = 1; i < n; i++) { cin >> t; d.pb(t - _t); _t = t; } sort(rall(d)); ll ans = k--; for (auto v : d) { if (k) { k--; continue; } ans += v; } cout << ans; return 0; }

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

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