제출 #28477

#제출 시각아이디문제언어결과실행 시간메모리
28477맞왜틀 맞왜틀 신나는노래~ 헤이! 나도한번 불러보자 (#68)Wine Tasting (FXCUP2_wine)C++98
1 / 1
116 ms6260 KiB
#include <cstdio>
#include <algorithm>
#include <vector>
int main(){
    int N,K;
    scanf("%d%d",&N,&K);
    std::vector<int> D(N+1);
    for(int i =1 ; i <= N; i++){
        scanf("%d",&D[i]);
    }
    std::sort(D.begin(),D.end());
    std::vector<int> ans;
    long long tot = 0;
    for(int i = 0; i<= K; i++){
        if(i%2 == 1){
            ans.push_back(D[D.size()-i/2-1]);
        }else ans.push_back(D[i/2]);

        if(ans.size() >= 2 && ans.back() - ans[ans.size()-2]>= 0){
            tot += ans.back() - ans[ans.size()-2];
        }
    }
    printf("%lld",tot);
}

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

wine.cpp: In function 'int main()':
wine.cpp:6:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&N,&K);
                        ^
wine.cpp:9:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&D[i]);
                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...