# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
89515 | 2018-12-15T07:43:00 Z | RAkhshon | Gift (IZhO18_nicegift) | C++17 | 2000 ms | 79884 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); 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()); if( x.fr-1 != 0 ) st.insert({x.fr-1,x.se}); ans.push_back(x.se); t--; } ///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 | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 456 KB | n=3 |
4 | Incorrect | 2 ms | 456 KB | Same heap occurs twice |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 456 KB | n=3 |
4 | Incorrect | 2 ms | 456 KB | Same heap occurs twice |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 456 KB | n=3 |
4 | Incorrect | 2 ms | 456 KB | Same heap occurs twice |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2029 ms | 79884 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | n=4 |
2 | Correct | 2 ms | 372 KB | n=3 |
3 | Correct | 2 ms | 456 KB | n=3 |
4 | Incorrect | 2 ms | 456 KB | Same heap occurs twice |
5 | Halted | 0 ms | 0 KB | - |