# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332252 | vitkishloh228 | Gift (IZhO18_nicegift) | C++14 | 2093 ms | 16300 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<stack>
#include<queue>
using namespace std;
int main() {
int n, k, t, cnt = 0, sum = 0, mx = -1;
cin >> n >> k;
priority_queue<pair<int, int> > pq, pq1;
for (int i = 0; i < n; i++) {
scanf("%d", &t);
mx = max(mx, t);
sum += t;
pq.push(make_pair(t, i + 1));
pq1.push(make_pair(t, i + 1));
}
while (pq.size() >= k)
{
stack<pair<int, int> > st;
for (int i = 0; i < k; i++) {
st.push(pq.top());
pq.pop();
}
for (int i = 0; i < k; i++) {
st.top().first--;
if (st.top().first != 0) pq.push(st.top());
st.pop();
}
cnt++;
}
if ((sum - mx) < (k - 1) * mx) {
printf("-1");
return 0;
}
printf("%d\n", cnt);
while (pq1.size() >= k)
{
printf("1 ");
stack<pair<int, int> > st;
for (int i = 0; i < k; i++) { st.push(pq1.top()); pq1.pop(); }
for (int i = 0; i < k; i++) { st.top().first--; if (st.top().first != 0) pq1.push(st.top()); printf("%d ", st.top().second); st.pop(); }
printf("\n");
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |