# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48530 | 2018-05-15T13:06:36 Z | Pajaraja | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 16432 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n,k,t,cnt=0; scanf("%d%d",&n,&k); priority_queue<pair<int,int> > pq,pq1; for(int i=0;i<n;i++) {scanf("%d",&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();} int f=st.top().first; if(!pq.empty()) f-=pq.top().first-1; for(int i=0;i<k;i++) {st.top().first-=f; if(st.top().first!=0) pq.push(st.top()); st.pop();} cnt++; } if(!pq.empty()) {printf("-1"); return 0;} printf("%d\n",cnt); while(pq1.size()>=k) { stack<pair<int,int> > st; for(int i=0;i<k;i++) {st.push(pq1.top()); pq1.pop();} int f=st.top().first; if(!pq1.empty()) f-=pq1.top().first-1; printf("%d ",f); for(int i=0;i<k;i++) {st.top().first-=f; if(st.top().first!=0) pq1.push(st.top()); printf("%d ",st.top().second); st.pop();} printf("\n"); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 356 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 484 KB | n=4 |
6 | Correct | 2 ms | 484 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 356 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 484 KB | n=4 |
6 | Correct | 2 ms | 484 KB | n=2 |
7 | Correct | 2 ms | 484 KB | n=5 |
8 | Correct | 2 ms | 544 KB | n=8 |
9 | Correct | 8 ms | 616 KB | n=14 |
10 | Correct | 5 ms | 616 KB | n=11 |
11 | Correct | 45 ms | 1980 KB | n=50000 |
12 | Correct | 56 ms | 2144 KB | n=50000 |
13 | Correct | 19 ms | 2144 KB | n=10 |
14 | Correct | 41 ms | 2144 KB | n=685 |
15 | Correct | 48 ms | 2144 KB | n=623 |
16 | Correct | 26 ms | 2144 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 356 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 484 KB | n=4 |
6 | Correct | 2 ms | 484 KB | n=2 |
7 | Correct | 2 ms | 484 KB | n=5 |
8 | Correct | 2 ms | 544 KB | n=8 |
9 | Correct | 8 ms | 616 KB | n=14 |
10 | Correct | 5 ms | 616 KB | n=11 |
11 | Correct | 45 ms | 1980 KB | n=50000 |
12 | Correct | 56 ms | 2144 KB | n=50000 |
13 | Correct | 19 ms | 2144 KB | n=10 |
14 | Correct | 41 ms | 2144 KB | n=685 |
15 | Correct | 48 ms | 2144 KB | n=623 |
16 | Correct | 26 ms | 2144 KB | n=973 |
17 | Correct | 44 ms | 2144 KB | n=989 |
18 | Correct | 19 ms | 2144 KB | n=563 |
19 | Correct | 30 ms | 2144 KB | n=592 |
20 | Correct | 30 ms | 2144 KB | n=938 |
21 | Correct | 23 ms | 2144 KB | n=747 |
22 | Correct | 26 ms | 2144 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2032 ms | 16432 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | n=4 |
2 | Correct | 2 ms | 356 KB | n=3 |
3 | Correct | 2 ms | 408 KB | n=3 |
4 | Correct | 2 ms | 484 KB | n=4 |
5 | Correct | 2 ms | 484 KB | n=4 |
6 | Correct | 2 ms | 484 KB | n=2 |
7 | Correct | 2 ms | 484 KB | n=5 |
8 | Correct | 2 ms | 544 KB | n=8 |
9 | Correct | 8 ms | 616 KB | n=14 |
10 | Correct | 5 ms | 616 KB | n=11 |
11 | Correct | 45 ms | 1980 KB | n=50000 |
12 | Correct | 56 ms | 2144 KB | n=50000 |
13 | Correct | 19 ms | 2144 KB | n=10 |
14 | Correct | 41 ms | 2144 KB | n=685 |
15 | Correct | 48 ms | 2144 KB | n=623 |
16 | Correct | 26 ms | 2144 KB | n=973 |
17 | Correct | 44 ms | 2144 KB | n=989 |
18 | Correct | 19 ms | 2144 KB | n=563 |
19 | Correct | 30 ms | 2144 KB | n=592 |
20 | Correct | 30 ms | 2144 KB | n=938 |
21 | Correct | 23 ms | 2144 KB | n=747 |
22 | Correct | 26 ms | 2144 KB | n=991 |
23 | Execution timed out | 2032 ms | 16432 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |