Submission #482359

#TimeUsernameProblemLanguageResultExecution timeMemory
482359lollipopGift (IZhO18_nicegift)C++17
0 / 100
651 ms91112 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define s second #define f first using namespace std ; const int mod = 1000000007 ; map < int , int > ma ; signed main(){ ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); int n , k ; cin >> n >> k ; vector < vector < int > > v ; multiset < pair < int , int > > se ; for( int j = 1 ; j <= n ; j ++ ){ int x ; cin >> x ; se.insert( { x , j } ) ; } while( se.size() > 0 ){ vector < int > ve ; if( se.size() < k ){ cout << -1 ; return 0 ; } int k1 = k - 1 ; pair < int , int > p ; p = *se.begin() ; int mn =p.f ; ve.pb( p.s ) ; se.erase( se.begin() ) ; while( k1 -- ){ pair < int , int > pa ; pa = *se.begin() ; ve.pb( pa.s ) ; se.erase( se.begin() ) ; pa.f -= mn ; if( pa.f != 0 ) se.insert( pa ) ; } ve.pb( p.f ) ; v.pb( ve ) ; } cout << v.size() << "\n"; for( int j = 0 ; j < v.size() ; j ++ ){ for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; } }

Compilation message (stderr)

nicegift.cpp: In function 'int main()':
nicegift.cpp:21:22: warning: comparison of integer expressions of different signedness: 'std::multiset<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   21 |        if( se.size() < k ){
      |            ~~~~~~~~~~^~~
nicegift.cpp:43:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |      for( int j = 0 ; j < v.size() ; j ++ ){
      |                       ~~^~~~~~~~~~
nicegift.cpp:44:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                       ~~^~~~~~~~~~~~~~~
nicegift.cpp:44:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |       ^~~
nicegift.cpp:44:79: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                                                                               ^~~~
#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...