# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89521 | 2018-12-15T08:13:30 Z | RAkhshon | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 79992 KB |
#include<bits/stdc++.h> #define ll long long #define fr first #define se second using namespace std; set< pair< ll, ll > > st; vector< ll > ans; int main(){ ll n, k; cin>>n>>k; for( ll i =1 ; i <= n ; i ++ ){ ll x; cin>>x; st.insert({x,i}); } /*** std::pair<ll,ll> x; x=*st.rbegin(); st.erase(x); ***/ ans.push_back(-1); std::vector< pair<ll,ll> > help; while( st.size()>k-1 ){ ll t = k; ans.push_back(1); while( t > 0 ){ std::pair< ll , ll > x; x=*st.rbegin(); st.erase(*st.rbegin()); ///cout<<x.fr<<'#'<<x.se<<endl; if( x.fr != 1 ) help.push_back({x.fr-1,x.se}); ans.push_back(x.se); t--; } ///cout<<help.size()<<'!'<<endl; if( help.size() != 0 ){ for( ll i = help.size()-1 ; i >= 0 ; i -- ) { st.insert(help[i]); } help.clear(); } ///cout<<st.size()<<endl; } if( st.size() < k && st.size()!=0 ){ cout<<-1; return 0; } cout<<(ans.size()-1)/(k+1)<<endl; for( ll i = 1; i < ans.size(); i ++ ){ cout<<ans[i]<<' '; if( (i)%(k+1)==0 ) cout<<endl; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 476 KB | n=3 |
3 | Correct | 2 ms | 476 KB | n=3 |
4 | Correct | 2 ms | 476 KB | n=4 |
5 | Correct | 2 ms | 476 KB | n=4 |
6 | Correct | 2 ms | 476 KB | n=2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 476 KB | n=3 |
3 | Correct | 2 ms | 476 KB | n=3 |
4 | Correct | 2 ms | 476 KB | n=4 |
5 | Correct | 2 ms | 476 KB | n=4 |
6 | Correct | 2 ms | 476 KB | n=2 |
7 | Correct | 2 ms | 476 KB | n=5 |
8 | Correct | 4 ms | 900 KB | n=8 |
9 | Correct | 34 ms | 1168 KB | n=14 |
10 | Correct | 22 ms | 1168 KB | n=11 |
11 | Correct | 147 ms | 4820 KB | n=50000 |
12 | Correct | 153 ms | 4820 KB | n=50000 |
13 | Correct | 108 ms | 4820 KB | n=10 |
14 | Correct | 97 ms | 4820 KB | n=685 |
15 | Correct | 110 ms | 4820 KB | n=623 |
16 | Correct | 63 ms | 4820 KB | n=973 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 476 KB | n=3 |
3 | Correct | 2 ms | 476 KB | n=3 |
4 | Correct | 2 ms | 476 KB | n=4 |
5 | Correct | 2 ms | 476 KB | n=4 |
6 | Correct | 2 ms | 476 KB | n=2 |
7 | Correct | 2 ms | 476 KB | n=5 |
8 | Correct | 4 ms | 900 KB | n=8 |
9 | Correct | 34 ms | 1168 KB | n=14 |
10 | Correct | 22 ms | 1168 KB | n=11 |
11 | Correct | 147 ms | 4820 KB | n=50000 |
12 | Correct | 153 ms | 4820 KB | n=50000 |
13 | Correct | 108 ms | 4820 KB | n=10 |
14 | Correct | 97 ms | 4820 KB | n=685 |
15 | Correct | 110 ms | 4820 KB | n=623 |
16 | Correct | 63 ms | 4820 KB | n=973 |
17 | Correct | 85 ms | 4820 KB | n=989 |
18 | Correct | 28 ms | 4820 KB | n=563 |
19 | Correct | 36 ms | 4820 KB | n=592 |
20 | Correct | 38 ms | 4820 KB | n=938 |
21 | Correct | 32 ms | 4820 KB | n=747 |
22 | Correct | 34 ms | 4820 KB | n=991 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2033 ms | 79992 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | n=4 |
2 | Correct | 2 ms | 476 KB | n=3 |
3 | Correct | 2 ms | 476 KB | n=3 |
4 | Correct | 2 ms | 476 KB | n=4 |
5 | Correct | 2 ms | 476 KB | n=4 |
6 | Correct | 2 ms | 476 KB | n=2 |
7 | Correct | 2 ms | 476 KB | n=5 |
8 | Correct | 4 ms | 900 KB | n=8 |
9 | Correct | 34 ms | 1168 KB | n=14 |
10 | Correct | 22 ms | 1168 KB | n=11 |
11 | Correct | 147 ms | 4820 KB | n=50000 |
12 | Correct | 153 ms | 4820 KB | n=50000 |
13 | Correct | 108 ms | 4820 KB | n=10 |
14 | Correct | 97 ms | 4820 KB | n=685 |
15 | Correct | 110 ms | 4820 KB | n=623 |
16 | Correct | 63 ms | 4820 KB | n=973 |
17 | Correct | 85 ms | 4820 KB | n=989 |
18 | Correct | 28 ms | 4820 KB | n=563 |
19 | Correct | 36 ms | 4820 KB | n=592 |
20 | Correct | 38 ms | 4820 KB | n=938 |
21 | Correct | 32 ms | 4820 KB | n=747 |
22 | Correct | 34 ms | 4820 KB | n=991 |
23 | Execution timed out | 2033 ms | 79992 KB | Time limit exceeded |
24 | Halted | 0 ms | 0 KB | - |