# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292981 | 2020-09-07T15:19:14 Z | Pajaraja | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 16168 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n,k,t,cnt=0,sum=0,mx=-1; scanf("%d%d",&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"); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | n=4 |
2 | Correct | 0 ms | 256 KB | n=3 |
3 | Correct | 1 ms | 256 KB | n=3 |
4 | Correct | 0 ms | 256 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 1 ms | 256 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | n=4 |
2 | Correct | 0 ms | 256 KB | n=3 |
3 | Correct | 1 ms | 256 KB | n=3 |
4 | Correct | 0 ms | 256 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 1 ms | 256 KB | n=2 |
7 | Correct | 0 ms | 256 KB | n=5 |
8 | Correct | 2 ms | 256 KB | n=8 |
9 | Correct | 10 ms | 384 KB | n=14 |
10 | Correct | 7 ms | 384 KB | n=11 |
11 | Correct | 65 ms | 2152 KB | n=50000 |
12 | Correct | 65 ms | 2156 KB | n=50000 |
13 | Correct | 34 ms | 768 KB | n=10 |
14 | Correct | 39 ms | 768 KB | n=685 |
15 | Correct | 41 ms | 888 KB | n=623 |
16 | Correct | 25 ms | 640 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | n=4 |
2 | Correct | 0 ms | 256 KB | n=3 |
3 | Correct | 1 ms | 256 KB | n=3 |
4 | Correct | 0 ms | 256 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 1 ms | 256 KB | n=2 |
7 | Correct | 0 ms | 256 KB | n=5 |
8 | Correct | 2 ms | 256 KB | n=8 |
9 | Correct | 10 ms | 384 KB | n=14 |
10 | Correct | 7 ms | 384 KB | n=11 |
11 | Correct | 65 ms | 2152 KB | n=50000 |
12 | Correct | 65 ms | 2156 KB | n=50000 |
13 | Correct | 34 ms | 768 KB | n=10 |
14 | Correct | 39 ms | 768 KB | n=685 |
15 | Correct | 41 ms | 888 KB | n=623 |
16 | Correct | 25 ms | 640 KB | n=973 |
17 | Correct | 37 ms | 760 KB | n=989 |
18 | Correct | 17 ms | 512 KB | n=563 |
19 | Correct | 30 ms | 888 KB | n=592 |
20 | Correct | 28 ms | 760 KB | n=938 |
21 | Correct | 21 ms | 640 KB | n=747 |
22 | Correct | 24 ms | 632 KB | n=991 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2076 ms | 16168 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | n=4 |
2 | Correct | 0 ms | 256 KB | n=3 |
3 | Correct | 1 ms | 256 KB | n=3 |
4 | Correct | 0 ms | 256 KB | n=4 |
5 | Correct | 1 ms | 256 KB | n=4 |
6 | Correct | 1 ms | 256 KB | n=2 |
7 | Correct | 0 ms | 256 KB | n=5 |
8 | Correct | 2 ms | 256 KB | n=8 |
9 | Correct | 10 ms | 384 KB | n=14 |
10 | Correct | 7 ms | 384 KB | n=11 |
11 | Correct | 65 ms | 2152 KB | n=50000 |
12 | Correct | 65 ms | 2156 KB | n=50000 |
13 | Correct | 34 ms | 768 KB | n=10 |
14 | Correct | 39 ms | 768 KB | n=685 |
15 | Correct | 41 ms | 888 KB | n=623 |
16 | Correct | 25 ms | 640 KB | n=973 |
17 | Correct | 37 ms | 760 KB | n=989 |
18 | Correct | 17 ms | 512 KB | n=563 |
19 | Correct | 30 ms | 888 KB | n=592 |
20 | Correct | 28 ms | 760 KB | n=938 |
21 | Correct | 21 ms | 640 KB | n=747 |
22 | Correct | 24 ms | 632 KB | n=991 |
23 | Execution timed out | 2076 ms | 16168 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |