제출 #108776

#제출 시각아이디문제언어결과실행 시간메모리
108776thebesStove (JOI18_stove)C++14
100 / 100
36 ms2168 KiB
#include <bits/stdc++.h>
using namespace std;

const int MN = 1e5+5;
typedef long long ll;
ll arr[MN], n, i, x, y, k, ans, r;

int main(){
    scanf("%lld%lld%lld",&n,&k,&x);
    r = k; k = max(0LL, n-k);
    for(i=2;i<=n;i++){
        scanf("%lld",&y);
        arr[i-1]=y-x; x=y;
    }
    sort(arr+1,arr+n,[](ll i,ll j){return i<j;});
    for(i=1;i<=k;i++) ans += arr[i];
    printf("%lld\n",ans+r);
    return 0;
}

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

stove.cpp: In function 'int main()':
stove.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld",&n,&k,&x);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
stove.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&y);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...