# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
61910 | khsoo01 | Zalmoxis (BOI18_zalmoxis) | C++11 | 379 ms | 10740 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int n, k;
vector<int> cur;
vector<pii> ans;
void upd () {
while(cur.size() >= 2) {
int A = cur.back();
cur.pop_back();
int B = cur.back();
cur.pop_back();
if(A != B) {
cur.push_back(B);
cur.push_back(A);
return;
}
else cur.push_back(A+1);
}
}
void print (int V) {
if(V && k) {
k--;
print(V-1);
print(V-1);
}
else {
printf("%d ",V);
return;
}
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) {
int T;
scanf("%d",&T);
while(!cur.empty() && T > cur.back()) {
ans.push_back({cur.back(), 1});
k--;
cur.push_back(cur.back());
upd();
}
ans.push_back({T, 0});
cur.push_back(T);
upd();
}
while(cur[0] < 30) {
ans.push_back({cur.back(), 1});
k--;
cur.push_back(cur.back());
upd();
}
for(auto &T : ans) {
int A, B;
tie(A, B) = T;
if(B) print(A);
else printf("%d ",A);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |