제출 #896531

#제출 시각아이디문제언어결과실행 시간메모리
896531duckindogStove (JOI18_stove)C++14
100 / 100
14 ms2016 KiB
// from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;
int n, k;
int t[N];
int d[N];

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> t[i];
  for (int i = 1; i < n; ++i) d[i] = t[i + 1] - t[i];
  sort(d + 1, d + n, greater<int>());
  int answer = k;
  for (int i = 1 + k - 1; i < n; ++i) answer += d[i];
  cout << answer;

}

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

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