제출 #732248

#제출 시각아이디문제언어결과실행 시간메모리
732248blackslexStove (JOI18_stove)C++17
100 / 100
29 ms2956 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 1e5 + 5;
ll n, m, a[N], ans;
vector<ll> v;

int main() {
    scanf("%lld %lld %lld", &n, &m, &a[1]);
    for (int i = 2; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
    sort(v.begin(), v.end());
    for (int i = 0; i < n - m; i++) ans += v[i];
    printf("%lld", ans + n);
}

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

stove.cpp: In function 'int main()':
stove.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%lld %lld %lld", &n, &m, &a[1]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for (int i = 2; i <= n; i++) scanf("%lld", &a[i]), v.emplace_back(a[i] - a[i - 1] - 1);
      |                                  ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...