Submission #89515

#TimeUsernameProblemLanguageResultExecution timeMemory
89515RAkhshonGift (IZhO18_nicegift)C++17
0 / 100
2029 ms79884 KiB
#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 (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:22:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 while( st.size()>k-1 ){
        ~~~~~~~~~^~~~
nicegift.cpp:35:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 if( st.size() < k && st.size()!=0  ){
     ~~~~~~~~~~^~~
nicegift.cpp:40:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for( ll i = 1; i < ans.size(); i  ++ ){
                ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...