제출 #97233

#제출 시각아이디문제언어결과실행 시간메모리
97233MohamedAhmed0Zalmoxis (BOI18_zalmoxis)C++14
0 / 100
350 ms8640 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAX = 2e6 + 10 ;
int freq[31] ;
vector<int>ans;
int n , k ;

void solve(int now)
{
    if(now == 30)
        return ;
    int occ = freq[now] ;
    if(occ % 2 == 0)
        freq[now+1] += occ / 2 ;
    else
    {
        ans.push_back(now) ;
        --k ;
        freq[now]++;
        freq[now+1] += (freq[now] / 2) ;
    }
    solve(now + 1) ;
}

int main()
{
    scanf("%d %d" , &n , &k) ;
    int MIN = 31 ;
    for(int i = 0 ; i < n ; ++i)
    {
        int x ;
        scanf("%d" , &x) ;
        ans.push_back(x) ;
        freq[ans[i]]++;
        MIN = min(MIN , ans[i]) ;
    }
    solve(MIN);
    sort(ans.rbegin() , ans.rend()) ;
    if(k > 0)
    {
        int x = ans.back();
        ans.pop_back();
        ans.push_back(x-1) ;
        ans.push_back(x-1) ;
    }
    for(auto &i : ans)
        cout<<i<<" ";
    return 0 ;
}

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

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