# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
97233 | MohamedAhmed0 | Zalmoxis (BOI18_zalmoxis) | C++14 | 350 ms | 8640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |